从NeuralRef的网站得到不同的结果?

2024-06-01 08:41:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用Neuralcoref查找共同引用。trial version of website给出的结果与我使用pip安装的版本不同。版本包括:

1. spacy==2.1.3 (as it will not work on spacy > 2.1.4)
2. neuralcoref==4.0

我测试的代码是:

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

# load NeuralCoref and add it to the pipe of SpaCy's model
import neuralcoref
neuralcoref.add_to_pipe(nlp)

# You're done. You can now use NeuralCoref as you usually manipulate a SpaCy document annotations.
doc = nlp(u'I love my father and my mother. They work hard. She is always nice but he is sometimes rude.')
print(doc._.coref_resolved)

它提供输出:

I love my father and my mother. my father and my mother work hard. my mother is always nice but he is sometimes rude.

与此示例类似:

# Input:

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

# Output:

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. the River Thames was founded by the Romans, who named the River Thames Londinium

在第一个例子中,问题是:它没有在最后一个例子中选择he作为对父亲的引用。你知道吗

在第二个例子中,问题是:它用River Thames代替London,这是错误的。你知道吗

但是在网站上,两个例子都很好。你知道吗

Example 1Example 2

不明白有什么区别?你知道吗


Tags: andofthenlpspacyisonmy