winkNLP Sentiment
Sentiment Analysis of Twitter Hashtag
This demo takes a Twitter hashtag and calculates the sentiments of the top tweets on that hashtag. It does this by using the out
method in winkNLP. It loads the tweet by using readDoc
and then outputs its.sentiment
.
How to build this
const winkNLP = require('wink-nlp');
const its = require( 'wink-nlp/src/its.js' );
const as = require( 'wink-nlp/src/as.js' );
const model = require('wink-eng-lite-model');
const nlp = winkNLP(model);
var sentiment = [];
var tweets = [
'I am so happy!',
'I am so sad'
];
tweets.forEach((t) => {
var tweetSentiment = nlp.readDoc(t).out(its.sentiment);
sentiment.push({
tweet: t,
sentiment: tweetSentiment
});
});
console.log(sentiment);