首页 > 解决方案 > NLP 共指解析

问题描述

我是 NLP 领域的新手,正在浏览这个博客: https ://blog.goodaudience.com/learn-natural-language-processing-from-scratch-7893314725ff

在此处输入图像描述

伦敦是英格兰和英国的首都和最大城市。伦敦位于英格兰东南部的泰晤士河畔,位于通向北海的 50 英里(80 公里)河口的顶端,两千年来一直是主要定居点。它是由罗马人建立的。

我有使用 spacy 进行 NER 和 POS 标记的经验。我想知道我将如何将伦敦联系起来,例如:

伦敦是首都......

这是一个主要的解决方案。

它是由罗马人建立的......

我已经尝试过依赖解析器,但无法产生相同的结果。 https://explosion.ai/demos/displacy

我愿意使用任何其他库,请提出正确的方法来实现它

标签: pythonnlpspacy

解决方案


您要解决的问题称为Coreference resolution

依赖解析器通常不是解决它的正确工具。

Spacy 有一个名为neurocoref的专用模块。也看看这个页面关于Spacy 的共指解析

一个例子:

import spacy
import neuralcoref

nlp = spacy.load('en_core_web_sm')

neuralcoref.add_to_pipe(nlp)
doc = nlp('London is the capital of and largest city in England and the United Kingdom. It was founded by the Romans.')

print(doc._.coref_clusters)
#output: [London: [London, It]]

希望这可以帮助


推荐阅读