AttributeError:“英语”对象没有属性“ noun_chunks”

时间:2019-02-21 03:04:37

标签: python python-3.x spacy

我正在尝试使用spacy noun_chunks,但它引发了错误。 我用下载了模型 python -m spacy download en_core_web_sm

AttributeError: 'English' object has no attribute 'noun_chunks'

NLP = spacy.load('en_core_web_sm')
NOUN_CHUNKS = NLP.noun_chunks

1 个答案:

答案 0 :(得分:0)

您是如何提出该代码的?加载的nlp处理对象没有属性noun_chunks –相反,您要访问已处理文档的名词块:

nlp = spacy.load("en_core_web_sm")  # load the English model
doc = nlp("There is a big dog.")    # process a text and create a Doc object
for chunk in doc.noun_chunks:       # iterate over the noun chunks in the Doc
   print(chunk.text)
# 'a big dog'

有关更多详细信息,请参见the documentation here