Функция предварительной обработки:
Код: Выделить всё
def preprocess_str_ml(txt):
tokenizer = TweetTokenizer()
lemmatizer = WordNetLemmatizer()
# convert all characters in the string to lower case
txt = txt.lower()
# remove non-english characters, punctuation and numbers
txt = re.sub('[^a-zA-Z]', ' ', txt)
# Tokenize the text
tokens = tokenizer.tokenize(txt)
# Lemmatization and removing stop words
lemmatized_tokens = [lemmatizer.lemmatize(token) for token in tokens]
txt = ' '.join(lemmatized_tokens)
txt = remove_stop_words(txt)
return txt
Код: Выделить всё
LookupError Traceback (most recent call last)
File /opt/conda/lib/python3.10/site-packages/nltk/corpus/util.py:80, in LazyCorpusLoader.__load(self)
79 except LookupError as e:
---> 80 try: root = nltk.data.find('{}/{}'.format(self.subdir, zip_name))
81 except LookupError: raise e
File /opt/conda/lib/python3.10/site-packages/nltk/data.py:653, in find(resource_name, paths)
652 resource_not_found = '\n%s\n%s\n%s' % (sep, msg, sep)
--> 653 raise LookupError(resource_not_found)
LookupError:
**********************************************************************
Resource 'corpora/wordnet.zip/wordnet/.zip/' not found. Please
use the NLTK Downloader to obtain the resource: >>>
nltk.download()
Searched in:
- '/root/nltk_data'
- '/usr/share/nltk_data'
- '/usr/local/share/nltk_data'
- '/usr/lib/nltk_data'
- '/usr/local/lib/nltk_data'
**********************************************************************
- Я попробовал загрузить полный пакет NLTK, используя nltk.download("all").
- Я также пытался загрузить "averaged_perceptron_tagger", как предлагали некоторые форумы.
Эти попытки были предприняты в среде блокнота Kaggle. Несмотря на эти усилия, ошибка остается неустраненной.
Подробнее здесь: https://stackoverflow.com/questions/776 ... -of-resour