【发布时间】:2020-06-11 16:09:53
【问题描述】:
我想使用 spacy 的模型 nl_core_news_sm 提取荷兰语文本的名词短语。 它返回一个空列表 另一方面,等效的英语模型 en_core_web_sm 确实提供了 noun_chunks (noun_phrases) 列表
这是正常的行为吗?即荷兰语模型不包括名词短语分隔符而英语模型呢?还是我做错了什么?
string='''In een wereld waarin je wordt overspoeld met informatie, is het prettig om een nieuwsbron te hebben met heldere stukken, die de ruimte laten om je eigen mening te vormen.'''
nlp = spacy.load('nl_core_news_sm')
print(dir(doc))
print(doc.noun_chunks)
list_chunks=[chunk for chunk in doc.noun_chunks]
for chunk in doc.noun_chunks:
print(chunk.text)
这里的结果是list_chunks是[] 当然,循环中不会打印任何内容
我使用 dir(doc) 来比较可用的方法,以便与英文模型进行比较。它们是一样的。
nlp_en = spacy.load('en_core_web_sm')
string='''They normally organises a wide range of activities for kids in the summer holidays. Due to the virus, these have all been cancelled'''
doc2=nlp_en(string)
print(dir(doc2))
print(doc2.noun_chunks)
for chunk in doc2.noun_chunks:
print(chunk.text)
在英语中它有效。
有什么想法吗?
【问题讨论】:
-
你能解决这个问题吗?我遇到了同样的问题,无法检索荷兰语文本的 noun_chunks
标签: spacy chunks language-model