我想使用
from nltk import word_tokenize, sent_tokenize, pos_tag
from nltk.stem.wordnet import WordNetLemmatizer
from nltk.corpus import wordnet
lmtzr = WordNetLemmatizer()
POS = pos_tag(text)
def get_wordnet_pos(treebank_tag):
#maps pos tag so lemmatizer understands
from nltk.corpus import wordnet
if treebank_tag.startswith('J'):
return wordnet.ADJ
elif treebank_tag.startswith('V'):
return wordnet.VERB
elif treebank_tag.startswith('N'):
return wordnet.NOUN
elif treebank_tag.startswith('R'):
return wordnet.ADV
else:
return wordnet.NOUN
lmtzr.lemmatize(text[i], get_wordnet_pos(POS[i][1]))
问题是 POS 标记器知道“procaspases”是“NNS”,但是我如何将 NNS 转换为 wordnet,因为即使在词形还原器之后,“procaspases”仍然是“procaspaseS”。