Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
AFINN-based sentiment analysis for Node.js.
JavaScript
tag: v0.1.0

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
build
lib
test
.gitignore
.travis.yml
LICENSE.md
README.md
makefile
package.json

README.md

sentiment

AFINN-based sentiment analysis for Node.js

Build Status

Sentiment is a Node.js module that uses the AFINN-111 wordlist to perform sentiment analysis on arbitrary blocks of input text.

Installation

npm install sentiment

Usage

var sentiment = require('sentiment');

sentiment('Cats are stupid.', function (err, result) {
    console.dir(result);    // Score: -2, Comparative: -0.666
});

sentiment('Cats are totally amazing!', function (err, result) {
    console.dir(result);    // Score: 4, Comparative: 1
});

Testing

npm test

Benchmarks

The primary motivation for designing sentiment was performance. As such, sentiment includes a benchmark script within the test directory that compares it against the Sentimental module by thinkroth. Based on these benchmarks from an older MacBook Air on Node 0.8.9, sentiment is about 97% faster than the alternative implementation:

sentiment
1000 operations  |  33ms
2000 operations  |  75ms
4000 operations  |  138ms
8000 operations  |  252ms
16000 operations |  506ms
32000 operations |  1120ms
64000 operations |  2268ms

--------------------------
--------------------------

Sentimental (by thnkroth)
1000 operations  |  1189ms
2000 operations  |  2392ms
4000 operations  |  4760ms
8000 operations  |  9469ms
16000 operations |  19513ms
32000 operations |  41018ms
64000 operations |  86931ms
Something went wrong with that request. Please try again.