-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver_summarize.js
More file actions
28 lines (26 loc) · 850 Bytes
/
server_summarize.js
File metadata and controls
28 lines (26 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var kue = require('kue');
var redis = require('kue/node_modules/redis');
var pythonShell = require('python-shell');
var url = require('url');
kue.redis.createClient = function() {
var redisUrl = url.parse(process.env.REDIS_URL)
, client = redis.createClient(redisUrl.port, redisUrl.hostname);
if (redisUrl.auth) {
client.auth(redisUrl.auth.split(":")[1]);
}
return client;
};
var jobs = kue.createQueue();
jobs.process('summarize', function(job, done) {
var text = "";
var pythonOptions = {
mode: 'text',
args: [job.data.textToSummarize, job.data.amount]
};
pythonShell.run('public/py/CleanAndExtract.py', pythonOptions, function (err, results) {
if (err) console.log(err);
console.log('PYTHONSHELL results: %j', results);
text = results;
});
done(null, text);
});