Sentimizer will measure sentiment around specific entities within text. It is built on NLTK, Spacy, and NRCLex. Output is a dictionary that can be analyzed further, graphed, formulated into a wordcloud, etc.
- https://github.com/explosion/spaCy
- https://github.com/nltk
- https://github.com/metalcorebear/NRCLex
- 2022-10-17: initial commit.
pip install sentimizer
from sentimizer import SentiMizer
analyzer = SentiMizer()
Loads initial body of text.
analyzer.load_text(text : str)
attributes:
analyzer.text
- attribute contains loaded text (str).
For appending additional text to the initial input.
analyzer.append_text(text : str)
For identifying entities within the loaded body of text.
analyzer.find_entities()
optional parameters:
entity_types_of_interest
- list of entity types for recognition. Default value is ['ORG', 'PERSON', 'FAC', 'GPE', 'LOC', 'EVENT']
All possible lables include: CARDINAL, DATE, EVENT, FAC, GPE, LANGUAGE, LAW, LOC, MONEY, NORP, ORDINAL, ORG, PERCENT, PERSON, PRODUCT, QUANTITY, TIME, WORK_OF_ART
For a description of each, visit https://spacy.io/models/en.
attributes:
analyzer.entities
- dictionary of entities and their tags (dict).
analyzer.sentences
- dictionary of entities and concatenated sentences containing each entity (dict). Keys are entities and values are the concatenated sentences mentioning that entity.
For measuring sentiment and emotional affect of sentences that mention each entity.
analyzer.emote()
attributes:
analyzer.sentiments
- Vader composite sentiment scores for each entity (dict). Keys are entities and values are the composite sentiment score for that entity.
analyzer.affect
- NRCLex affect scores for each entity (dict). Keys are entities and the values are affect frequency dictionaries.
optional parameters:
entity_type
- string specifying the entity type to analyze. Default value is None
. Default action is the analyze all entity types.