Introduction

wink-sentiment

Accurate and fast sentiment scoring of phrases with emoticons :) & emojis 🎉

Build Status Coverage Status devDependencies Status

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:

  1. Intelligent negation handling; for example, phrase "good product" will get a positive score whereas "not a good product" gets a negative score.
  2. Automatic detection and scoring of two-word phrases in a text; for example, "cool stuff", "well done", and "short sighted".
  3. Processes each emoji and/or emoticon separately while scoring.
  4. Achieves accuracy of 77%, when validated using Amazon Product Review Sentiment Labelled Sentences Data Set at UCI Machine Learning Repository.

Installation

Use npm to install:

npm install wink-sentiment --save

Documentation

For detailed API docs, check out http://winkjs.org/wink-sentiment/ URL!

Need Help?

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.

Copyright & License

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.

analyzeSentiment

Computes the absolue and normalized sentiment scores of the input phrase. 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.

analyzeSentiment(phrase: string): object
Parameters
phrase (string) — whoes sentiment score needs to be computed.
Returns
object: — absolute score and normalizedScore of phrase .
Example
analyzeSentiment( 'not a good product' );
// -> { score: -3, normalizedScore: -1 }
analyzeSentiment( 'Excited to be part of the @imascientist team for the next couple of weeks!' );
// { score: 3, normalizedScore: 0.21428571428571427 }