sentiment travis-ci npm

AFINN-based sentiment analysis for Node.js.

2 years after

sentiment

AFINN-based sentiment analysis for Node.js

Build Status Coverage Status Dependency Status devDependency Status

Sentiment is a Node.js module that uses the AFINN-165 wordlist to perform sentiment analysis on arbitrary blocks of input text. Sentiment provides several 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

Usage

var sentiment = require('sentiment');

var r1 = sentiment('Cats are stupid.');
console.dir(r1);        // Score: -2, Comparative: -0.666

var r2 = sentiment('Cats are totally amazing!');
console.dir(r2);        // Score: 4, Comparative: 1

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 = require('sentiment');

var result = sentiment('Cats are totally amazing!', {
    'cats': 5,
    'amazing': 2  
});
console.dir(result);    // 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 (Latest) x 544,714 ops/sec ±0.83% (99 runs sampled)
Sentimental (1.0.1) x 269,417 ops/sec ±1.06% (96 runs sampled)

To run the benchmarks yourself, simply:

make benchmark

Testing

npm test

Related Repositories

Sentiment-Analysis-Twitter

Sentiment-Analysis-Twitter

:mortar_board:RESEARCH:smirk_cat: [NLP :thought_balloon:] We use different featu ...

sentiment-server

sentiment-server

Simple, Modular Microservice For Language Sentiment ...

sentiment-thermometer

sentiment-thermometer

Measure the sentiment towards a word, name or sentence on social networks ...

sentiment-2017-imavis

sentiment-2017-imavis

From Pixels to Sentiment: Fine-tuning CNNs for Visual Sentiment Prediction ...

laravel-sentiment-analysis

laravel-sentiment-analysis

A Laravel wrapper to perform sentiment analysis over an English sentence ...


Top Contributors

thisandagain greenkeeperio-bot andjosh EvanHahn monteslu MicahFulton

Releases

-   v0.2.1 zip tar
-   v0.2.0 zip tar
-   v0.1.0 zip tar