Sentiment

sentiment

AFINN-based sentiment analysis.

Sentiment uses AFINN-111 wordlist to perform sentiment analysis on arbitrary blocks of input text.

Sentiment provides serveral things:

  • Performance.
  • The ability to append and overwrite word / value pairs from the AFINN wordlist.
  • A build process that makes updating sentiment to future versions of the AFINN word list trivial.

Get it: npm install --save sentiment

Sample usage:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
> var sentiment = require('sentiment');

> sentiment('Cats are stupid');
{ score: -2,
  comparative: -0.6666666666666666,
  tokens: [ 'cats', 'are', 'stupid' ],
  words: [ 'stupid' ],
  positive: [],
  negative: [ 'stupid' ] }

> sentiment('Cats are cool');
{ score: 1,
  comparative: 0.3333333333333333,
  tokens: [ 'cats', 'are', 'cool' ],
  words: [ 'cool' ],
  positive: [ 'cool' ],
  negative: [] }

> sentiment('Cats are cool',{'cats':5,'cool':10});
{ score: 15,
  comparative: 5,
  tokens: [ 'cats', 'are', 'cool' ],
  words: [ 'cool', 'cats' ],
  positive: [ 'cool', 'cats' ],
  negative: [] }

GIF FTW!

sentiment.gif

Thanks to Andrew Sliwinski for this crazy module!

Suggest a module

Comments