Skip to content
Finn Årup Nielsen edited this page Aug 2, 2019 · 1 revision

FAQ

Is it possible to extend the AFINN dictionary in afinn?

Well, yes. There is no stable interface for that, but hidden functions can be used.

from afinn import Afinn

afinn = Afinn(language='en')

afinn._dict.update({'coffee': -2, 'tea': +7})

print(afinn.score('coffee or tea?'))

afinn._setup_pattern_from_dict()

print(afinn.score('coffee or tea?'))

Here the first print prints 0.0 while the second prints 5.0.

Clone this wiki locally