tommy.model.stopwords_model
Classes
- class tommy.model.stopwords_model.StopwordsModel(derive_from: StopwordsModel = None)[source]
Bases:
object
A class representing the set of stopwords.
The class acts as a wrapper around a set of stopwords, providing basic iterable-like functionality. Initially it represents the set of basic/general stopwords imported from a text file, but extra words may be added, removed or replaced.
- __init__(derive_from: StopwordsModel = None) None [source]
Initializes the stopwords model.
- add(*args: str | Iterable[str]) None [source]
Adds one or more extra stopwords.
- Parameters:
args – The word(s) to add
- Returns:
None
- property default_words: set[str]
- property extra_words: set[str]
- property extra_words_in_order: list[str]
- classmethod from_dict(stopwords_dict: dict) StopwordsModel [source]
Create a StopwordsModel instance from a dictionary representation.
- Parameters:
stopwords_dict – Dictionary representation of the stopwords
- Returns:
StopwordsModel instance
- remove(*args: str | Iterable[str]) None [source]
Remove one or more extra stopwords.
- Parameters:
args – The word(s) to remove
- Returns:
None
- replace(word_set: set[str], words_in_order: list[str]) None [source]
Replace the extra stopwords with a new set of stopwords.
- Parameters:
word_set – The new words to replace the old ones with
words_in_order – The new words, but in the order that the user
supplied them. This is necessary to make sure the order stays the same when switching config. :return: None