与 spacy 和 wikidata 链接的实体

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

我正在处理 NYT 文章并使用 spacy 来查找命名实体。对于其中一些(特别是 PERSON 和 ORG),我想将它们链接到标识符,例如,我希望将“Barack Obama”和“President Obama”识别为同一实体。

我想使用一个可用的知识库,例如 wikidata,并发现了两个我有问题的包:

我试过spacyopentapiocahttps://spacy.io/universe/project/spacyopentapioca)但是当我运行示例代码时

import spacy
nlp = spacy.blank('en')
nlp.add_pipe('opentapioca')
doc = nlp('Christian Drosten works in Germany.')
for span in doc.ents:
    print((span.text, span.kb_id_, span.label_, span._.description, span._.score))

我收到以下错误消息: HTTPError:500 服务器错误:url 的内部服务器错误:https://opentapioca.org/api/annotate

我试过spacy-entity-linkerhttps://github.com/egerber/spaCy-entity-linker

安装有效,但在终端中运行 `python -m spacy_entity_linker "download_knowledge_base"` 无效,当我运行包中的示例代码时:

nlp = spacy.load("en_core_web_md") 
nlp.add_pipe("entityLinker", last=True)
doc = nlp("I watched the Pirates of the Caribbean last silvester")
all_linked_entities = doc._.linkedEntities
for sent in doc.sents:
    sent._.linkedEntities.pretty_print()

我得到错误:URLError:

spacy wikidata entity-linking
© www.soinside.com 2019 - 2024. All rights reserved.