https://github.com/cmpadden/afinn.ts
AFINN Sentiment Analysis Ported to Typescript
https://github.com/cmpadden/afinn.ts
Last synced: 10 months ago
JSON representation
AFINN Sentiment Analysis Ported to Typescript
- Host: GitHub
- URL: https://github.com/cmpadden/afinn.ts
- Owner: cmpadden
- Created: 2022-02-22T20:50:07.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-02-24T18:54:06.000Z (over 4 years ago)
- Last Synced: 2025-02-05T23:25:08.413Z (over 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 213 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AFINN
[](https://www.npmjs.com/package/afinn.ts)
[](https://github.com/cmpadden/afinn.ts/actions)
AFINN sentiment analysis: a wordlist-based approach to sentiment analysis
ported from the [Python implementation](https://github.com/fnielsen/afinn) to Typescript.
## Installation
```
yarn add afinn.ts
```
## Demo
A demonstration of the `afinn.ts` module can be found in use at [https://cmpadden.github.io/afinn.ts-demo/](https://cmpadden.github.io/afinn.ts-demo/) with source code in the
[cmpadden/afinn.ts-demo](https://github.com/cmpadden/afinn.ts-demo) repository.

## Examples
```ts
import Afinn from "afinn.ts";
const afinn = Afinn({ language: "en" });
afinn.score("This is utterly excellent!");
```
In Danish:
```ts
const afinn = Afinn({ language: "da" });
afinn.score("Hvis ikke det er det mest afskyelige flueknepperi...");
```
In Finnish:
```ts
const afinn = Afinn({ language: "fi" });
afinn.score("Siellä on uusi hyvä juttu, katsokaa ja kuunnelkaa ihmeessä.");
```
In Swedish:
```ts
const afinn = Afinn({ language: "sv" });
afinn.score("det är inte bra");
```
In Turkish:
```ts
const afinn = Afinn({ language: "tr" });
afinn.score("iyi de\u011Fil");
```
```ts
const afinn = Afinn({ language: "tr" });
afinn.score("iyi değil");
```
With emoticons:
```ts
const afinn = Afinn({ language: "emoticons" });
afinn.score("I saw that yesterday :)");
```
_NOTE:_ there are plans to add _emoticon_ support to all languages, as is done in the Python implementation.
## Citation
Nielsen's original citation can be found here:
> Finn Årup Nielsen, "A new ANEW: evaluation of a word list for sentiment analysis in microblogs", Proceedings of the ESWC2011 Workshop on 'Making Sense of Microposts': Big things come in small packages. Volume 718 in CEUR Workshop Proceedings: 93-98. 2011 May. Matthew Rowe, Milan Stankovic, Aba-Sah Dadzie, Mariann Hardey (editors)