
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Sentiment analysis of natural language with afinn-165
and
emoji-emotion
.
You can give this package words, and it’ll tell you the valence (“goodness” vs “badness”), and which words are positive or negative.
You can use this with your own tokenizer to do some simple sentiment analysis.
This package is ESM only. In Node.js (version 14.14+, 16.0+), install with npm:
npm install polarity
In Deno with esm.sh
:
import {polarity} from 'https://esm.sh/polarity@4'
In browsers with esm.sh
:
<script type="module">
import {polarity} from 'https://esm.sh/polarity@4?bundle'
</script>
import {polarity} from 'polarity'
polarity(['some', 'positive', 'happy', 'cats'])
Yields:
{
polarity: 5,
positivity: 5,
negativity: 0,
positive: ['happy', 'positive'],
negative: []
}
polarity(['darn', 'self-deluded', 'abandoned', 'dogs'])
Yields:
{
polarity: -4,
positivity: 0,
negativity: -4,
positive: [],
negative: ['abandoned', 'self-deluded']
}
This package exports the identifier polarity
, inject
, and polarities
.
There is no default export.
polarity(words[, inject])
Get a polarity result from given values, optionally with one time injections.
👉 Note:
polarity
does not tokenize values. There are good tokenizers around (such asparse-latin
). However, the following will work pretty good:
function tokenize(value) { return value.toLowerCase().match(/\S+/g) }
words
(Array<string>
) — words to checkinject
(Record<string, number>
, optional) — custom valences for wordsObject with the following fields:
polarity
(number
) — calculated polarity of inputpositivity
(number
) — total positivitynegativity
(number
) — total negativitypositive
(Array<string>
) — all positive wordsnegative
(Array<string>
) — all negative wordsinject(words)
Insert custom values.
polarities
Direct access to the internal values (Record<string, number>
).
This package is fully typed with TypeScript.
It exports the additional type Polarity
(the result).
This package is at least compatible with all maintained versions of Node.js. As of now, that is Node.js 14.14+ and 16.0+. It also works in Deno and modern browsers.
afinn-165
— AFINN list from 2015, containing 3382 entriesemoji-emotion
— like AFINN, but for emojiYes please! See How to Contribute to Open Source.
This package is safe.
FAQs
Detect the polarity (sentiment) of text
The npm package polarity receives a total of 31 weekly downloads. As such, polarity popularity was classified as not popular.
We found that polarity demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.