-
Notifications
You must be signed in to change notification settings - Fork 0
/
classify.js
29 lines (24 loc) · 1.03 KB
/
classify.js
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
29
var natural = require('natural'),
classifier = new natural.BayesClassifier();
classifier.addDocument('my arm broked', 'search');
classifier.addDocument('i have broken arm what can i do?', 'search');
classifier.addDocument('my nose is bleeding', 'search');
classifier.addDocument('what can i do about broken arm', 'search');
classifier.addDocument('I have bleeding arm', 'search');
classifier.addDocument('wake me up qqqq', 'alarm');
classifier.addDocument('set alarm q\'s', 'alarm');
classifier.addDocument('qqqq call', 'call');
classifier.addDocument('call q\'s', 'call');
classifier.addDocument('how is weather', 'weather');
classifier.addDocument('where i can find xxx', 'location');
classifier.addDocument('where is nearest', 'location');
classifier.addDocument('where is hospital', 'location');
classifier.addDocument('where is pharmacy', 'location');
classifier.train();
function classify(query,callback) {
console.log(classifier.getClassifications(query));
return callback(null ,classifier.classify(query))
}
module.exports = {
classify
}