← all repositories
thisandagain/sentiment

Fast AFINN sentiment scoring for Node.js, with emoji support

A lightweight, pluggable sentiment analyzer that trades neural-network complexity for raw speed and hackability.

2.7k stars JavaScript Other AI
sentiment
Velocity · 7d
+0.5
★ / day
Trend
steady
star history

What it does

sentiment scores text for emotional valence using the AFINN-165 word list and an emoji sentiment ranking. You get a total score, a per-token average, and lists of which words registered as positive or negative. It is about as sophisticated as a weighted Scrabble tile bag, but that is the point.

The interesting bit

The library is deliberately extensible: you can register new languages, inject custom word scores on the fly, and even define per-language scoring strategies for negation or emphasis. The French example in the README shows flipping a word’s score when preceded by “pas” — crude, but it works.

Key highlights

  • Benchmarked at ~861K ops/sec against a comparable library’s ~451K on Node v6.9.1 (MacBook Pro)
  • Validation accuracy hovers around 70–77% on Amazon, IMDB, and Yelp datasets
  • Supports emoji sentiment out of the box
  • extras option lets you override AFINN scores or add domain-specific vocabulary without forking
  • Callback and synchronous APIs both supported

Caveats

  • Tokenization is naive: split on whitespace, strip special characters. No stemming, no phrase detection, no sarcasm handling
  • The “no options supported currently” note on the constructor suggests some API surface is still placeholder
  • Accuracy in the mid-70s is respectable for a lexicon approach, but will miss anything requiring context or word order beyond immediate negation

Verdict

Good fit if you need quick, explainable sentiment scoring in Node.js and can tolerate lexicon-level simplicity. Skip it if you need nuanced understanding, multilingual coverage beyond what you build yourself, or state-of-the-art accuracy.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.