Skip to content

Commit

Permalink
Merge pull request #177 from oudalab/yan-dev
Browse files Browse the repository at this point in the history
#175 make the topic model interface fucntional and need coders to giv…
  • Loading branch information
YanLiang1102 authored Jun 29, 2017
2 parents 661f1fb + 9bd7b8f commit fb5ceba
Show file tree
Hide file tree
Showing 17 changed files with 90,592 additions and 19 deletions.
14 changes: 14 additions & 0 deletions app/models/documentswithtopic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var mongoose = require("mongoose");

module.exports = mongoose.model('documentswithtopic', {
id: {
type: String
},
document: {
type: String
},
topic: {
type: Number
}
/*this is a database first model, need to define the collection name this model mapped to here*/
},"documentswithtopic");
87 changes: 81 additions & 6 deletions app/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var VerbDictionary = require('./models/verbDictionary');
var User = require('./models/user');
var Sentence = require('./models/sentence');
var SentenceTaggingResult = require('./models/sentenceTaggingResult');
var Documentswithtopic=require('./models/documentswithtopic');
var mongoose = require('mongoose');
/*var ObjectId = require('mongoose').Types.ObjectId;*/
var request = require('request');
Expand Down Expand Up @@ -436,12 +437,6 @@ module.exports = function(app) {
}).exec(function(err, count) {
var randomnumber=Math.random();
var random = Math.floor(randomnumber * count);
//var limitcount=0;
/* if(randomnumber<0.5)
{
var random=Math.floor((randomnumber+0.25)*count);
}*/
//var queryword=req.param('word');

Sentence.findOne({
"tagged": false,
Expand Down Expand Up @@ -734,6 +729,84 @@ module.exports = function(app) {
});
});

app.post('/getOneQuerySentence', function(req, res) {
var r = new RegExp(".*" + req.param('word'), 'i');
Sentence.count({
"tagged": false,
"wholeSentence": {
$regex: r
}
}).exec(function(err, count) {
var randomnumber=Math.random();
var random = Math.floor(randomnumber * count);

Sentence.findOne({
"tagged": false,
"wholeSentence": {
$regex: r
}
}).limit(1).skip(random).exec(
function(err, result) {
if (result != null) {
res.json(result);
} else {
res.json({
'output': 'notfound'
});
console.log("find 0 sentence with this query");
}
}
)

});

});

app.post('/findDocumentsWithTopic',function(req,res){
var topicno=parseInt(req.body.topic)-1
Documentswithtopic.count({
"topic": topicno

}).exec(function(err, count) {
var randomnumber=Math.random();
var random = Math.floor(randomnumber * count);

Documentswithtopic.findOne({
"topic": topicno

}).limit(1).skip(random).exec(
function(err, result) {
if(err)
{
res.end();
}
if (result != null) {
res.json(result['document']);

} else {
res.json({
'output': 'notfound'
});
res.end();
/*console.log("find 0 sentence with this query");*/
}

}
)


});

/* //console.log("topic "+req.body.topic);
Documentswithtopic.findOne({
'topic': parseInt(req.body.topic)
}, function(err, data) {
res.json(data['document']);
//console.log(data[0]);
res.end();
});*/
});


//update the verb code in verb dictionary
app.post('/updateVerbDictionary', function(req, res) {
Expand All @@ -753,6 +826,8 @@ module.exports = function(app) {
res.end();
});



//update source didctionary based on sourceDictionaryId
app.post('/updateSourceDictionary', function(req, res) {
SourceDictionary.findOneAndUpdate({
Expand Down
22 changes: 22 additions & 0 deletions nohup.out
Original file line number Diff line number Diff line change
Expand Up @@ -24245,3 +24245,25 @@ info: Forever processing file: server.js
127.0.0.1 - - [21/Jun/2017 10:20:29] "POST /ar HTTP/1.1" 200 -
127.0.0.1 - - [21/Jun/2017 12:09:07] "POST /ar HTTP/1.1" 200 -
127.0.0.1 - - [21/Jun/2017 12:09:10] "POST /ar HTTP/1.1" 200 -
127.0.0.1 - - [21/Jun/2017 12:23:49] "POST /ar HTTP/1.1" 200 -
127.0.0.1 - - [21/Jun/2017 12:23:52] "POST /ar HTTP/1.1" 200 -
127.0.0.1 - - [21/Jun/2017 12:23:55] "POST /ar HTTP/1.1" 200 -
127.0.0.1 - - [21/Jun/2017 12:23:57] "POST /ar HTTP/1.1" 200 -
123.151.42.61 - - [21/Jun/2017 13:35:55] "GET http://www.baidu.com/ HTTP/1.1" 404 -
warn: --minUptime not set. Defaulting to: 1000ms
warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
info: Forever processing file: server.js
* Running on http://0.0.0.0:9090/ (Press CTRL+C to quit)
58.213.133.130 - - [22/Jun/2017 23:15:10] "GET http://www.sciencedirect.com/science/jrnlallbooks/a HTTP/1.1" 404 -
warn: --minUptime not set. Defaulting to: 1000ms
warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
info: Forever processing file: server.js
* Running on http://0.0.0.0:9090/ (Press CTRL+C to quit)
warn: --minUptime not set. Defaulting to: 1000ms
warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
info: Forever processing file: server.js
* Running on http://0.0.0.0:9090/ (Press CTRL+C to quit)
127.0.0.1 - - [24/Jun/2017 18:39:46] "POST /ar HTTP/1.1" 200 -
123.151.42.61 - - [26/Jun/2017 17:18:56] "GET http://www.baidu.com/ HTTP/1.1" 404 -
124.112.228.45 - - [27/Jun/2017 00:17:25] "GET /manager/html HTTP/1.1" 404 -
123.151.42.61 - - [28/Jun/2017 18:02:58] "GET http://www.baidu.com/ HTTP/1.1" 404 -
Binary file removed otherHelperCode/.english_docs_20top.out.swp
Binary file not shown.
Loading

0 comments on commit fb5ceba

Please sign in to comment.