🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

@oxi-dev0/sentiment-js

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oxi-dev0/sentiment-js

Multilanguage and emojis AFINN-based sentiment analysis for Node.js

0.0.9
latest
Source
npm
Version published
Maintainers
1
Created
Source

sentiment-js

Text and emojis sentiment analysis for Node.js

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

Multilanguage, only full support for english and french (PR contributions are welcome)

It has full support on emoji analysis.

Language detection if not provided at call.

Sentiment analysis is suitable at a sentence level, for long strings, please tokenize sentences and use sentiment on every chunk.

This project is a fork of nicolasbonnici's fork of the original sentiment project: https://github.com/nicolasbonnici/sentiment

Usage

Installation

npm install @oxi-dev0/sentiment-js --save

// Require the node-sentiment module
var sentiment = require('@oxi-dev0/sentiment-js');

// Use the module to get sentiment from texts.

// Vote: 'negative'
console.dir(sentiment('Cats are stupid.','en'));

// Vote: 'negative' and english detected
console.dir(sentiment('Cats are stupid.'));

// Vote: 'positive', english detected and negation detected
console.dir(sentiment('Cats are not so stupid.'));

// Vote: 'positive'
console.dir(sentiment('Cats are totally amazing! ♥','en'));

// Vote: 'negative'
console.dir(sentiment('I gatti sono stupidi. 😭','it'));

// Sample response for "Seems somebody had a good meal! @wildelifeanimal #lion #safari #cats #wildlife #Africa #adventure #offroad https://t.co/6cX7hAlrYY ♥"
{
  score: 8,
  comparative: 0.5,
  vote: 'positive',
  tokens:
   [ 'seems',
     'somebody',
     'had',
     'a',
     'good',
     'meal',
     '@wildelifeanimal',
     'lion',
     'safari',
     'cats',
     'wildlife',
     'africa',
     'adventure',
     'offroad',
     'httpstco6cx7halryy',
     '♥' ],
  words: [ '♥', 'adventure', 'good' ],
  positive: [ '♥', 'adventure', 'good' ],
  negative: [],
  language: 'en'
}

You can also play with node-sentiment in a terminal.

node cli.js "Cats are not so cool..."

Test

npm test

Changelog

Keywords

sentiment

FAQs

Package last updated on 29 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts