sentiment.Lexicon

Token-polarity lookup: AFINN base scores layered with coding-domain overrides.

Usage

Source

sentiment.Lexicon()

DOMAIN_OVERRIDES pins context-specific terms (stop, broken, ship) that AFINN mis-scores, and magnitudes below MIN_MAGNITUDE collapse to neutral. Backs the lexicon-bearing score stages through has_hit().

Methods

Name Description
has_hit() Whether any token in text reaches floor (<= -floor when want_negative).
polarity() The signed polarity of lemma.

has_hit()

Whether any token in text reaches floor (<= -floor when want_negative).

Usage

Source

has_hit(text, *, floor, want_negative)

Uses the Rust udpipe backend (lemmatize + score) when available; otherwise the spaCy path, which fails open (returns True) when spaCy/afinn are unavailable.


polarity()

The signed polarity of lemma.

Usage

Source

polarity(lemma)

A domain override when present, else its AFINN score zeroed below MIN_MAGNITUDE.