AFINN sentiment analysis in Python: Wordlist-based approach for sentiment analysis.
Examples
>>> from afinn import Afinn
>>> afinn = Afinn()
>>> afinn.score('This is utterly excellent!')
3.0
In Danish:
>>> afinn = Afinn(language='da')
>>> afinn.score('Hvis ikke det er det mest afskyelige flueknepperi...')
-6.0
With emoticons:
>>> afinn = Afinn(emoticons=True)
>>> afinn.score('I saw that yesterday :)')
2.0
With multiple sentences (here with data from an Austen novel available in Gutenberg):
>>> from afinn import Afinn
>>> from nltk.corpus import gutenberg
>>> import textwrap
>>> afinn = Afinn()
>>> sentences = (" ".join(wordlist) for wordlist in gutenberg.sents('austen-sense.txt'))
>>> scored_sentences = ((afinn.score(sent), sent) for sent in sentences)
>>> sorted_sentences = sorted(scored_sentences)
>>> print("\n".join(textwrap.wrap(sorted_sentences[0][1], 70)))
To attach myself to your sister , therefore , was not a thing to be
thought of ;-- and with a meanness , selfishness , cruelty -- which no
indignant , no contemptuous look , even of yours , Miss Dashwood , can
ever reprobate too much -- I was acting in this manner , trying to
engage her regard , without a thought of returning it .-- But one
thing may be said for me : even in that horrid state of selfish vanity
, I did not know the extent of the injury I meditated , because I did
not THEN know what it was to love .
Citation
If you as a scientist use the wordlist or the code please cite this one:
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)
Paper with supplement: http://www2.imm.dtu.dk/pubdb/views/edoc_download.php/6006/pdf/imm6006.pdf
See also
http://neuro.compute.dtu.dk/wiki/AFINN - Brede Wiki entry on AFINN with pointers to many scientific papers
https://github.com/darenr/afinn - Sentiment analysis in Javascript with AFINN word list
Travis et al.
Metadata
Release files for afinn 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| afinn-0.1.tar.gz | 52.6 kB | Without provenance | Details for afinn-0.1.tar.gz |
Release files / afinn-0.1.tar.gz
| Download URL | afinn-0.1.tar.gz |
|---|---|
| Size | 52.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cf2f728ccc6f2974f2f27e2110e4c05a0133a2f14a40387c463a8c9fdd4ab61b
|
|
BLAKE2b-256 checksum How to use checksums |
86e5ffbb7ee3cca21ac6d310ac01944fb163c20030b45bda25421d725d8a859a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for afinn 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.