为什么BLEU得分为这对零,即使它们相似
为什么即使句子相似,为什么要获得0分。 请参考下面的分数值为“ 0”
from nltk.translate.bleu_score import sentence_bleu
score = sentence_bleu(['where', 'are', 'economic', 'networks'], ['where', 'are', 'the', 'economic', 'network'])
print(score)
如果您运行上述代码,
why I'm getting 0 score even though sentences are similar. Please refer the code below
from nltk.translate.bleu_score import sentence_bleu
score = sentence_bleu(['where', 'are', 'economic', 'networks'], ['where', 'are', 'the', 'economic', 'network'])
print(score)
score value is '0' if u run the above code
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这与您将引用对该方法交付有关。
查看 documentation> //github.com/nltk/nltk/blob/develop/nltk/nltk/translate/bleu_score.py#l28“ rel =“ nofollow noreferrer”>此如何使用它的示例。
参考必须是列表(所有参考翻译的列表以将假设与假设进行比较)。因此,在您的情况下,包含一个令牌化参考翻译的列表。
这样使用它,它将起作用:
尽管我必须承认我以前曾在完全相同的问题上挣扎,但这对NLTKS的一部分不是很直观。文档甚至指出,引用必须为类型
list(list(str))
,但是不检查是否是这种情况,而是在使用错误时返回误导性结果。This has to do with how you hand the references to the method.
Check out the documentation or more specifically this sample of how to use it.
References have to be a list (a list of all reference translations to compare the hypothesis with). So in your case a list containing the one tokenized reference translation.
Use it like this and it will work:
Although I have to admit I have struggled with the exact same problem before and this is not very intuitive on NLTKs part. The documentation even states that references has to be of type
list(list(str))
but then doesn't check if this is the case and instead returns a misleading result when used incorrectly.