include method to remove stopwords#163
Conversation
JiwaniZakir
left a comment
There was a problem hiding this comment.
The @cached_property decorator in blob.py is incompatible with the fname parameter on remove_stopwords — cached properties are accessed as attributes (e.g., blob.remove_stopwords), not called as methods, so the fname argument can never actually be passed by a caller and the default "stopwords.txt" is baked in permanently. The relative path "stopwords.txt" will also raise a FileNotFoundError for any caller whose working directory isn't the project root; it should resolve to an absolute path using os.path.join(os.path.dirname(__file__), ...) or leverage NLTK's built-in nltk.corpus.stopwords, which TextBlob already depends on. Additionally, the return type is a plain str rather than a TextBlob instance, which breaks method chaining and is inconsistent with the rest of the API (e.g., words returns a WordList). The method name itself should be a noun (e.g., clean_text or filtered_words) to match the property convention used throughout the class.
included method to remove stopwords from text.
here is an example with the blob text:
... should produce the following output