![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
node-sentiment
Advanced tools
Multilanguage and emojis AFINN-based 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)
He 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 the original sentiment project: https://github.com/thisandagain/sentiment
npm install node-sentiment --save
// Require the node-sentiment module
var sentiment = require('node-sentiment');
// 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..."
npm test
package.json update to remove mocha from production dependencies npm lock file added
Fix on tokenize method and integration test added on it
Whole code review Basic CLI interface added and project renamed to node-sentiment for npm package
Negation detection fix Language detection feature POC added
FAQs
Multilanguage and emojis AFINN-based sentiment analysis for Node.js
We found that node-sentiment demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.