Skip to content

Instantly share code, notes, and snippets.

@nicinabox
Created December 5, 2014 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicinabox/6b0486bb1ce812806f5d to your computer and use it in GitHub Desktop.
Save nicinabox/6b0486bb1ce812806f5d to your computer and use it in GitHub Desktop.
var _ = require('lodash');
var natural = require('natural'),
classifier = new natural.BayesClassifier();
// First item denotes "changed motor oil"
var notes = [
[true, 'Change oil, oil filter, air filter, spark plugs'],
[true, 'Change oil, oil filter. 4qt Rotella T6, 0.5 Mobil 1 5W-40'],
[false, 'Change gearbox oil, rear drive oil, valve adjustment, torque heads'],
[false, 'Change transmission oil'],
[false, 'Change headlight fluid']
];
_.each(notes, function(n) {
classifier.addDocument(n[1], (n[0] ? 'changed motor oil' : ''));
});
classifier.train();
console.log(
classifier.classify('Change power steering fluid')
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment