使用词形还原器打印单词的词根

问题描述 投票:0回答:1

您好,我第一次使用 nltk,我收到一个错误,我不知道如何排除故障,感谢您的帮助!

import nltk


nltk.download('wordnet')
lemmatizer = WordNetLemmatizer()

x = 'was'
y = 'is'

lemma = lemmatizer.lemmatize(x, 'v')
print(lemma)  # Output: be```

The error that I am getting is that the wordnet resource is not found. I am running in Pycharm and using python as the language.

```LookupError: 
**********************************************************************
  Resource wordnet not found.
  Please use the NLTK Downloader to obtain the resource:```
python nlp pycharm nltk
1个回答
0
投票

只需在下载后、运行词形还原之前导入 WordNetLemmatizer:

from nltk.stem import WordNetLemmatizer
© www.soinside.com 2019 - 2024. All rights reserved.