Accurate and fast sentiment scoring of phrases with emoticons :) & emojis 🎉
Analyze sentiment of tweets, product reviews, social media content or any text using wink-sentiment
. It is a part of wink — a growing family of high quality packages for Statistical Analysis, Natural Language Processing and Machine Learning in NodeJS.
It is based on AFINN and Emoji Sentiment Ranking; it's features include:
Use npm to install:
npm install wink-sentiment --save
For detailed API docs, check out http://winkjs.org/wink-sentiment/ URL!
If you spot a bug and the same has not yet been reported, raise a new issue or consider fixing it and sending a pull request.
wink-sentiment is copyright 2017 GRAYPE Systems Private Limited.
It is licensed under the under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3 of the License.
Computes the absolue and normalized sentiment scores of the input phrase
,
after tokenizing it.
The normalized score is computed by dividing the absolute score by the number
of tokens; this is always between -5 and +5. A score of less than 0 indicates
negative sentiments and a score of more than 0 indicates positive sentiments;
wheras a near zero score suggests a neutral sentiment. While counting tokens
only the ones tagged as word
, emoji
, or emoticon
are counted;
and one letter words are ignored.
It performs tokenization using wink-tokenizer. During sentiment analysis, each token may be assigned up to 3 new properties. These properties are:
score
— contains the sentiment score of the word, which is always
between -5 and +5. This is added only when the word in question has a positive or
negative sentiment associated with it.negation
— is added & set to true whenever the score
of the
token has beeen impacted due to a negation word apprearing prior to it.grouped
— is added whenever, the token is the first
word of a short idom or a phrase. It's value provides the number of tokens
that have been grouped together to form the phrase/idom.(string)
— whoes sentiment score needs to be computed.
object
:
— absolute
score
,
normalizedScore
and
tokenizedPhrase
of
phrase
.
sentiment( 'not a good product' );
// -> { score: -3,
// normalizedScore: -1,
// tokenizedPhrase: [
// { token: 'not', tag: 'word' },
// { token: 'a', tag: 'word' },
// { token: 'good', tag: 'word', negation: true, score: -3 },
// { token: 'product', tag: 'word' }
// ]
// }
sentiment( 'Excited to be part of the @imascientist team:-)!' );
// -> { score: 5,
// normalizedScore: 0.625,
// tokenizedPhrase: [
// { token: 'Excited', tag: 'word', score: 3 },
// { token: 'to', tag: 'word' },
// { token: 'be', tag: 'word' },
// { token: 'part', tag: 'word' },
// { token: 'of', tag: 'word' },
// { token: 'the', tag: 'word' },
// { token: '@imascientist', tag: 'mention' },
// { token: 'team', tag: 'word' },
// { token: ':-)', tag: 'emoticon', score: 2 },
// { token: '!', tag: 'punctuation' }
// ]
// }