Skip to content

Commit

Permalink
fixed a runner exception
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4f53 committed Nov 23, 2023
1 parent 328c7fc commit 3edf140
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions text_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,13 @@ def regional_pii(text):
from nltk.corpus import stopwords

try:
if not nltk.data.find('tokenizers/punkt'): nltk.download('punkt')
if not nltk.data.find('chunkers/maxent_ne_chunker'): nltk.download('maxent_ne_chunker')
if not nltk.data.find('corpora/words.zip'): nltk.download('words')
nltk_resources = ["tokenizers/punkt", "chunkers/maxent_ne_chunker", "corpora/words.zip"]
for resource in nltk_resources:
if not nltk.data.find(resource): raise LookupError()
except LookupError:
nltk.download('punkt')
nltk.download('maxent_ne_chunker')
nltk.download('stopwords')
nltk.download('words')

stop_words = set(stopwords.words('english'))
Expand Down

0 comments on commit 3edf140

Please sign in to comment.