nlp - 如何调整 neuralcoref 以获得更好的共指结果?

标签 nlp python-3.7 spacy

我正在使用 neuralcoref - 一个基于 spaCy 解析器的共指解析模块。 GIT https://github.com/huggingface/neuralcoref

但是,我得到的结果可以改进。 huggingface(neuralcoref 的开发者)提供的在线可视化工具为我提供了更准确的结果。

我正在分析的文本: "伦敦是英格兰和英国的首都和人口最多的城市。它位于大不列颠岛东南部的泰晤士河畔,两千年来一直是主要的定居点。"

我得到这个结果:

doc._.coref_resolved 

London is the capital and most populous city of England and the United Kingdom. Standing on the River Thames in the south east of the island of Great Britain, the River Thames has been a major settlement for two millennia.

所以它错误地将伦敦与泰晤士河联系起来。 (它 -> 泰晤士河)

neuralcoref 在线可视化工具返回正确的链接(it -> London)

https://huggingface.co/coref/?text=London%20is%20the%20capital%20and%20most%20populous%20city%20of%20England%20and%20the%20United%20Kingdom.%20Standing%20on%20the%20River%20Thames%20in%20the%20south%20east%20of%20the%20island%20of%20Great%20Britain%2C%20it%20has%20been%20a%20major%20settlement%20for%20two%20millennia.%20It%20was%20founded%20by%20the%20Romans%2C%20who%20named%20it%20Londinium .

我已经尝试过调整参数,例如项目的 git 页面上提到的贪婪度、max_dist https://github.com/huggingface/neuralcoref

import spacy
nlp = spacy.load('en_core_web_lg')

import neuralcoref
neuralcoref.add_to_pipe(nlp,greedyness=0.5,store_scores=True)

text = "London is the capital and most populous city of England and   the United Kingdom. Standing on the River Thames in the south east of the island of Great Britain, it has been a major settlement for two millennia."# It was founded by the Romans, who named it Londinium."

doc = nlp(text)
print(doc._.coref_resolved)
doc._.coref_scores

有没有办法调整它以获得与可视化工具类似的结果?

谢谢!

最佳答案

不知道为什么在线工具会更好用(在线可视化工具不适合我)。

你可以做的是添加一个对话库:

coref = neuralcoref.NeuralCoref(nlp.vocab, conv_dict={'London': ['city', 'settlement']})

https://reposhub.com/python/deep-learning/huggingface-neuralcoref.html

我有自己的问题,对荷兰语根本不起作用..

关于nlp - 如何调整 neuralcoref 以获得更好的共指结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56710356/

相关文章:

python - 获取由 spacy 解析器创建的每个 token 的 Spacy.Vocab.Morphology id

python - 有没有更快的方法循环遍历集合并替换句子中的 MWE? - Python

nlp - 如何获取单词的语义类型?

google-app-engine - python 3.7 的运行时实用程序 API 替代方案 |谷歌应用引擎

python-3.7 - 如何在同一行代码中使用字符串 (str) 和整数 (int)?

Python strptime 不解析时区 EST %z

python - 使 Spacy 分词器不拆分为/

machine-learning - 用于日记条目情感分析的数据集

nlp - 创建包含部分的 Spacy Doc

aws-lambda - SpaCy 模型无法在 AWS Lambda 中加载