【发布时间】:2021-02-16 07:01:47
【问题描述】:
我一直在关注 Lemmatization 的教程 -> https://www.machinelearningplus.com/nlp/lemmatization-examples-python/
如 spacy lemmatization 部分所述,我加载了 'en-core-web-sm' 模型,从给定句子中解析并提取每个单词的词元。
我的代码如下
nlp = spacy.load('en_core_web_sm', disable=['parser', 'ner'])
sentence = "The striped bats are hanging on their feet for best"
doc = nlp(sentence)
lemmatized_spacy_output = " ".join([token.lemma_ for token in doc])
print(lemmatized_spacy_output)
输入
"The striped bats are hanging on their feet for best"
它给出的输出为
the stripe bat be hang on their foot for good
而预期的输出是
the strip bat be hang on -PRON- foot for good'
可以看出,stripes 词应该被识别为动词,但由于某种原因它被归类为名词(因为输出是条带,而不是条带)。
此外,它不是识别人称代词,而是按原样给出标记。
我已经尝试了很多 github 和 stackoverflow 问题,但没有一个针对我的查询。
【问题讨论】:
-
本教程看起来像是针对 spaCy v2.x 而不是 v3.x,其中一些行为已经改变。
-
@aab 我的 spacy 版本显示 3.0.3。您能否详细说明 spacy 3.x 中的哪些行为发生了变化?
标签: spacy pos-tagger lemmatization