-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmain.js
More file actions
22 lines (17 loc) · 672 Bytes
/
main.js
File metadata and controls
22 lines (17 loc) · 672 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var Corpus = require('./lib/corpus');
var Document = require('./lib/document');
var SentimentClassifier = require('./lib/classifier');
var Classifier = function(positivePath, negativePath) {
var positiveCorpus = new Corpus();
var negativeCorpus = new Corpus();
if (!positivePath) positivePath = __dirname + '/data/positive';
if (!negativePath) negativePath = __dirname + '/data/negative';
positiveCorpus.loadFromDirectory(positivePath);
negativeCorpus.loadFromDirectory(negativePath);
return {
classify: function(text) {
return new SentimentClassifier(positiveCorpus, negativeCorpus).classify(text);
}
};
};
module.exports = Classifier;