monkeylearn-node
Official Node client for the MonkeyLearn API. Build and consume machine learning models for language processing from your Node apps.
Install
You can use npm to install the library:
npm install monkeylearn
Usage examples
Here are some examples of how to use the library in order to create and use classifiers:
var MonkeyLearn, ml, p, module_id, root_id, negative_id, positive_id, samples;
MonkeyLearn = require('monkeylearn');
ml = new MonkeyLearn('<YOUR API KEY HERE>');
p = ml.classifiers.create('Test Classifier').then(function (res) {
module_id = res.result.classifier.hashed_id
return ml.classifiers.detail(module_id);
}).then(function (res) {
root_id = res.result.sandbox_categories[0].id
return ml.classifiers.categories.create(module_id, 'Negative', root_id);
}).then(function (res) {
negative_id = res.result.category.id
return ml.classifiers.categories.create(module_id, 'Positive', root_id);
}).then(function (res) {
positive_id = res.result.category.id
samples = [['The movie was terrible, I hated it.', negative_id], ['I love this movie, I want to watch it again!', positive_id]];
return ml.classifiers.uploadSamples(module_id, samples);
}).then(function (res) {
return ml.classifiers.train(module_id);
}).then(function (res) {
return ml.classifiers.classify(module_id, ['I love the movie', 'I hate the movie'], true);
}).then(function (res) {
console.log(res.result);
});
You can also use the sdk with extractors and pipelines:
var MonkeyLearn = require('monkeylearn');
var ml = new MonkeyLearn('<YOUR API KEY HERE>');
var res = ml.extractors.extract('<Extractor ID>', ['Some text for the extractor.', 'Some more text']);
var res = ml.pipelines.run('<Pipeline ID>', {'input':[{'text': 'some text for the pipeline.'}]}, false);