mysamai / natural-brain

A natural language classifier using Node Natural with a BrainJS neural network
MIT License
320 stars 29 forks source link

How can I return the value of classification ? #30

Closed ghost closed 6 years ago

ghost commented 6 years ago

var BrainJSClassifier = require('natural-brain'); var classifier = new BrainJSClassifier();

classifier.addDocument('my unit-tests failed.', 'software'); classifier.addDocument('tried the program, but it was buggy.', 'software'); classifier.addDocument('tomorrow we will do standup.', 'meeting'); classifier.addDocument('the drive has a 2TB capacity.', 'hardware'); classifier.addDocument('i need a new power supply.', 'hardware'); classifier.addDocument('can you play some new music?', 'music');

classifier.train();

////////SERVER METHOD

'sendToServer':function(message){ var classification = classifier.classify(message); console.log(classification); //=> print classificaiton return classification; //=> return undefined }

daffl commented 6 years ago

classifier.getClassifications(message) will return an object with all classifications.

It is the same interface as https://github.com/NaturalNode/natural#classifiers

ghost commented 6 years ago

Hmm, I think I solve it by doing in another way. Thank you anyway.

daffl commented 6 years ago

I'm using this right in https://github.com/mysamai/mysam/blob/master/lib/services/classify/classify.class.js#L40