Skip to content

Commit

Permalink
Fix POSTagTransformer, TextPreprocessingTransformer recipes (#203)
Browse files Browse the repository at this point in the history
* `nltk.pos_tag` function expects a `list[str]` for the `token` param

* Get the same behaviour as with nltk v3.4.3
  • Loading branch information
this authored Jun 21, 2024
1 parent e1647fd commit deed860
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions transformers/nlp/text_pos_tagging_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def set_tagger(self):
nltk.download('averaged_perceptron_tagger', download_dir=nltk_data_path)
try:
self.pos_tagger = nltk.pos_tag
self.pos_tagger("test")
self.pos_tagger(list("test"))
except LookupError:
os.makedirs(nltk_data_path, exist_ok=True)
os.makedirs(nltk_temp_path, exist_ok=True)
Expand All @@ -40,7 +40,7 @@ def set_tagger(self):
self.atomic_copy(file1, tagger_path)
self.atomic_copy(file2, tagger_path)
self.pos_tagger = nltk.pos_tag
self.pos_tagger("test")
self.pos_tagger(list("test"))

def __init__(self, **kwargs):
super().__init__(**kwargs)
Expand Down
4 changes: 2 additions & 2 deletions transformers/nlp/text_preprocessing_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(self, **kwargs):
self.lemmatizer = nltk.stem.WordNetLemmatizer()
self.pos_tagger = nltk.pos_tag
self.lemmatizer.lemmatize("test", wordnet.NOUN)
self.pos_tagger("test")
self.pos_tagger(list("test"))
except LookupError:
os.makedirs(nltk_data_path, exist_ok=True)
os.makedirs(nltk_temp_path, exist_ok=True)
Expand All @@ -92,7 +92,7 @@ def __init__(self, **kwargs):
self.lemmatizer = nltk.stem.WordNetLemmatizer()
self.pos_tagger = nltk.pos_tag
self.lemmatizer.lemmatize("test", wordnet.NOUN)
self.pos_tagger("test")
self.pos_tagger(list("test"))
self.wordnet_map = {"N": wordnet.NOUN,
"V": wordnet.VERB,
"J": wordnet.ADJ,
Expand Down

0 comments on commit deed860

Please sign in to comment.