【问题标题】:can't get ROUGE score with pyrouge无法使用 pyrouge 获得 ROUGE 分数
【发布时间】:2018-05-17 08:22:38
【问题描述】:

我正在对文本摘要进行实验。得到解码后的句子和参考句后,我用pyrouge得到ROUGE分数,python代码如下:

from pyrouge import Rouge155
r=Rouge155()
r.model_filename_pattern = '#ID#——reference.txt'
r.system_filename_pattern = '(\d+)_decoded.txt'
r.model_dir = '/home/test/reference'
r.system_dir = '/home/test/decoded'

rouge_results = r.convert_and_evaluate()
print rouge_results
output_dict = r.output_to_dict(output)

但它似乎不起作用,它报告了一个subprocess.CalledProcessError

Illegal division by zero at /.../.../ROUGE/RELEASE-1.5.5/ROUGE-1.5.5.pl

这里是具体的错误信息:

Traceback (most recent call last):
   File "rouge.py", line 28, in <module>
       rouge_results = r.convert_and_evaluate()
   File "/home/username/env/local/lib/python2.7/site-packages/pyrouge-0.1.3.py2.7.egg/pyrouge/Rouge155.py", line 364, in convert_and_evaluate
       rouge_output = self.evaluate(system_id, rouge_args)
   File "/home/username/env/local/lib/python2.7/site-packages/pyrouge-0.1.3.py2.7.egg/pyrouge/Rouge155.py", line 339, in evaluate
       rouge_output = check_output(command).decode("UTF-8")
   File "/usr/lib/python2.7/subprocess.py", line 574, in check_output
       raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '[u'/home/username/env/ROUGE/RELEASE-1.5.5/ROUGE-1.5.5.pl', '-e', '/home/username/env/ROUGE/RELEASE-1.5.5/data', '-c', '95','-2', '-1', '-U', '-r', '1000', '-n','4','-w','1.2','-a',u'-m', u' /tmp/tmpG9VKo9/rouge_conf.xml']' returned non-zero exit status 255

有人遇到过这种问题吗?感谢任何建议!非常感谢!

【问题讨论】:

  • 欢迎来到 Stack Overflow!请以文本形式包含完整的错误,而不是错误的屏幕截图。
  • 谢谢!我已经添加了完整的错误信息:)

标签: python text summarization


【解决方案1】:

我发现这个问题是由参考句子中的&lt;s&gt;&lt;/s&gt;引起的。我删除了这些符号,最后得到了ROUGE分数。

【讨论】:

    【解决方案2】:

    总的来说,我发现您必须从摘要中删除所有标签,例如:&lt;something&gt;。就我而言,我使用以下指令删除&lt;n&gt;

    summary.replace('<n>', '')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-13
      • 2021-06-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多