JavaScript wrapper for the Sentiment140 Natural Language Processing Service.
npm install sentiment140 [--save]
var Sentiment140 = require('sentiment140');
var sentiment140 = new Sentiment140({
auth: '[INSERT YOUR EMAIL HERE]'
});
Takes a simple string.
var dataSimple = {
"data": {
"text": "I am a Teapot and a Submarine"
}
}
sentiment140.sentiment(dataSimple, function(error, result) {
console.log(JSON.stringify(result));
});
[Missing]
Takes an array of simple strings.
var dataBulk = {
"data": [
{"text": "I love Titanic.", "id": 1 },
{"text": "I hate Titanic.", "id": 2 },
{"text": "I like Titanic.", "id": 3 }
]
}
sentiment140.sentiment(dataBulk, function(error, result) {
console.log(JSON.stringify(result));
});
[Missing]
The sentiment140 library now supports both traditional callback return functions as well as Promises. Sentiment140 uses the bluebird library for the promise implementation.
Peter Andreas Moelgaard (GitHub, Twitter)
Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0