我有纯文本格式的摘要,希望得到胭脂的分数

您可以这样评估纯文本摘要:

from pyrouge import Rouge155
r = Rouge155()
r.system_dir = 'path/to/system_summaries'
r.model_dir = 'path/to/model_summaries'
r.system_filename_pattern = 'some_name.(\d+).txt'
r.model_filename_pattern = 'some_name.[A-Z].#ID#.txt'
output = r.convert_and_evaluate()
print(output)
output_dict = r.output_to_dict(output)

为了评估总结,Rouge需要知道你的总结在哪里

金本位的总结是,以及如何匹配它们。胭脂

用语言来说,你的总结是“系统”总结和黄金标准

摘要是“模型”摘要。摘要应该分开

文件夹,其路径设置为system_dir和model_dir

变量。所有摘要每行应包含一个句子。

自动将系统摘要与相应模型匹配

总结一下,pyrouge使用正则表达式。例如,假设

系统摘要使用固定名称和

变量数字标识如下:

一些名称.001.txt

一些名.002.txt

一些名称.003.txt

模型总结如下,用大写字母标识

给定文档的多个模型摘要:

一些名称.a.001.txt

一些名称.B.001.txt

一些名称.c.001.txt

一些名称.a.002.txt

一些名称.B.002.txt

system_filename_pattern中的组告诉pyrouge

文件名是id–在本例中是(\d+)。你必须使用圆

括号表示一个组,否则pyrouge将无法分辨

除了ID和文件名的其他部分。然后用那个身份证

查找所有匹配的模型摘要。特殊占位符#ID#

告诉Pyrouge它应该在哪里

model_filename_pattern。[A-Z]部分匹配多个模型

该ID的摘要。

完成配置后,调用convert_and_evaluate()get

你这胭脂是一串串的。如果您想进一步处理

分数,你可以用

output_to_dict(output)。

我只想预处理我的摘要,然后自己运行胭脂

要将纯文本摘要转换为Rouge能理解的格式,请执行以下操作:

from pyrouge import Rouge155
Rouge155.convert_summaries_to_rouge_format(system_input_dir, system_output_dir)
Rouge155.convert_summaries_to_rouge_format(model_input_dir, model_output_dir)
这将转换system_input_dir和
model_input_dir,并将它们保存到各自的输出中
目录。
生成Rouge用来匹配系统和
模型摘要,do:from pyrouge import Rouge155
Rouge155.write_config_static(
system_dir, system_filename_pattern,
model_dir, model_filename_pattern,
config_file_path)

前四个论点在上面解释过。config_file_path

指定保存配置文件的位置。

从命令行使用pyrouge

如果您更喜欢命令行而不是python和pyrouge模块,则可以

使用以下脚本,这些脚本将自动安装并应

在系统的任何地方都可以运行:pyrouge_evaluate_plain_文本文件获得胭脂评分

你的纯文本摘要。示例:pyrouge_evaluate_plain_text_files -s systems_plain/ -sfp "some_name.(\d+).txt" -m models_plain/ -mfp some_name.[A-Z].#ID#.txtpyrouge_evaluate_rouge_format_文件获得胭脂分数

对于已转换为胭脂格式的摘要。示例用法

胭脂附带的sample-test/SL2003数据:pyrouge_evaluate_rouge_format_files -s systems -sfp "SL.P.10.R.11.SL062003-(\d+).html" -m models -mfp SL.P.10.R.[A-Z].SL062003-#ID#.html

注意,系统文件名模式用引号括起来

因为它包含特殊字符。pyrouge\u将纯文本转换为红色格式转换

将纯文本文件转换为胭脂能理解的格式。如果你的纯文本

文件每行不包含一个句子,此脚本还可以

分句,只要你有nltk和它的punkt语句

已安装拆分器。示例:pyrouge_convert_plain_text_to_rouge_format -i models_plain/ -o models_rougepyrouge_write_config_文件创建配置文件可以用来自己涂胭脂。示例:pyrouge_write_config_file -s systems -sfp "SL.P.10.R.11.SL062003-(\d+).html" -m models -mfp SL.P.10.R.[A-Z].SL062003-#ID#.html -c sl2003_config.xml

使用-h选项运行其中任何一个都将显示一条用法消息

解释各种命令行选项。

安装

有关安装胭脂的说明

here。

根据您的系统,您可能需要运行以下命令

作为根。

要安装pyrouge,请运行:pip install pyrouge

假设是工作胭脂-1.5.5。安装,告诉烟火胭脂

使用此命令的路径:pyrouge_set_rouge_path /absolute/path/to/ROUGE-1.5.5/directory

要测试是否安装正确,请运行:python -m pyrouge.test

如果一切正常,您应该看到如下内容:Ran 10 tests in 18.055s

OK

如果要卸载pyrouge:pip uninstall pyrouge


推荐PyPI第三方库

PyPI 帮助安装包程序

上传Python包

用户指南

常见问题

关于 PyPIPyPI 分享

设施仪表板

包索引名称

赞助商

Contributing to PyPI错误和反馈

贡献GitHub

翻译 PyPI

开发 credits

使用 PyPI行为准则

网站地图

隐私政策

使用条款

服务器状态: 正常