- What is this?
- When should I use this?
- Install
- Use
- API
- Musings
- Types
- Compatibility
- Related
- Contribute
- Security
- License
This package gives you easy access to AFINN-96.
You should likely use afinn-165 instead.
This package is ESM only. In Node.js (version 14.14+, 16.0+), install with npm:
npm install afinn-96In Deno with esm.sh:
import {afinn96} from 'https://esm.sh/afinn-96@2'In browsers with esm.sh:
<script type="module">
import {afinn96} from 'https://esm.sh/afinn-96@2?bundle'
</script>import {afinn96} from 'afinn-96'
afinn96.positive // => 2
afinn96['fed up'] // => -3This package exports the identifier afinn96.
There is no default export.
afinn-96 maps entries to valence ratings (Record<string, number>).
👉 Note: Be careful when accessing unknown properties on the
afinn-96object, words such asconstructorortoStringmight occur. It’s recommended to use ahasOwnPropertycheck beforehand.
Note the AFINN entries are:
- all lower case
- can contain spaces (cases:
can't stand,cashing in,cool stuff,does not work,dont like,fed up,green wash,green washing,messing up,no fun,not good,not working,right direction,screwed up,some kind) - can contain apostrophes (only case:
can't stand) - can contain dashes (cases:
cover-up,made-up,short-sighted,short-sightedness,son-of-a-bitch)
This package is fully typed with TypeScript. It exports no additional types.
This package is at least compatible with all maintained versions of Node.js. As of now, that is Node.js 14.14+, 16.0+, and 18.0+. It also works in Deno and modern browsers.
afinn-111— AFINN list from 2011, containing 2477 entriesafinn-165— AFINN list from 2015, containing 3382 entriesemoji-emotion— like AFINN, but for emojipolarity— detect the polarity of text, based onafinn-165andemoji-emotion
Yes please! See How to Contribute to Open Source.
This package is safe.