sentiment custom lists - AFINN-based sentiment analysis for Node.js
This project is a fork of thisandagain/sentiment. This project do the same as the original project and add support to use other AFINN like lists to do sentiment analysis
Original description
Sentiment is a Node.js module that uses the AFINN-111 wordlist to perform sentiment analysis on arbitrary blocks of input text. Sentiment provides serveral things:
- Performance (see benchmarks below)
- 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
Installation
npm install sentiment-custom-lists
Usage
var sentiment = ; var r1 = ;consoledirr1; // Score: -2, Comparative: -0.666 var r2 = ;consoledirr2; // Score: 4, Comparative: 1
Usage with another list
("de_de" list currently not existing)
var sentiment = ; var r1 = ;consoledirr1; // Score: -2, Comparative: -0.666
Adding / overwriting words
You can append and/or overwrite values from AFINN by simply injecting key/value pairs into a sentiment method call:
var sentiment = ; var result = ;consoledirresult; // Score: 7, Comparative: 1.75
Benchmarks
The primary motivation for designing sentiment
was performance. As such, it includes a benchmark script within the test directory that compares it against the Sentimental module which provides a nearly equivalent interface and approach. Based on these benchmarks, running on a MacBook Pro with Node 0.12.7, sentiment
is twice as fast as alternative implementations:
sentiment x 544,714 ops/sec ±0.83% Sentimental x 269,417 ops/sec ±1.06%
To run the benchmarks yourself, simply:
make benchmark
Testing
npm test