我想在 Ubuntu 中安装 pyrouge 以进行文本摘要评估。我使用 this 中的说明.
首先我写了 pip install pyrouge
然后我必须写这个命令:pyrouge_set_rouge_path/absolute/path/to/ROUGE-1.5.5/directory
。
在我的系统中我写道:
pyrouge_set_rouge_path /home/afsharizadeh/anaconda3/lib/python3.6/site-packages/pyrouge
得到这个:
Exception: Cannot set data directory because the path /home/afsharizadeh/anaconda3/lib/python3.6/site-packages/pyrouge/data does not exist.
还有
pyrouge_set_rouge_path /home/afsharizadeh/pyrouge-0.1.0/pyrouge
得到这个:
Exception: Cannot set data directory because the path /home/afsharizadeh/pyrouge-0.1.0/pyrouge/data does not exist.
还有
pyrouge_set_rouge_path /home/afsharizadeh/pyrouge-0.1.0/pyrouge/test
得到这个:
Exception: ROUGE binary not found at /home/afsharizadeh/pyrouge-0.1.0/pyrouge/test/ROUGE-1.5.5.pl. Please set the correct path by running pyrouge_set_rouge_path /path/to/rouge/home.
我知道关于这个问题的类似问题在堆栈溢出中被问到,但我无法解决我的问题,因为我根本不知道这个表达式“ROUGE path”是什么意思。 “通往 ROUGE-1.5.5 的路径”是什么意思?
我知道我有两个关于 pyrouge 的目录。其中一个是这个路径:~/anaconda3/lib/python3.6/site-packages/pyrouge
另一个是我从站点下载它的目录。这个路径是:~/pyrouge-0.1.0
。该目录还有其他三个名称相同的目录:bin、pyrouge、pyrouge.egg-info。
基于 this page我用这种格式写的:
set pyrouge_set_rouge_path=/home/afsharizadeh/anaconda3/lib/python3.6/site-packages/pyroug
在这种格式之后,没有出现错误,但是在那之后我输入:
python -m pyrouge.test
我收到这个错误:
Exception: Cannot set data directory because the path /home/afsharizadeh/anaconda3/lib/python3.6/site-packages/pyroug/data does not exist.
---------------------------------------------------------------------- Ran 11 tests in 0.592s
FAILED (errors=9)
我该怎么办?
最佳答案
要遵循的所有步骤(仅适用于 Linux):
第 1 步:从源代码安装 Pyrouge(不是从 pip
)
git clone https://github.com/bheinzerling/pyrouge
cd pyrouge
pip install -e .
第二步:安装官方ROUGE脚本
git clone https://github.com/andersjo/pyrouge.git rouge
第 3 步:将 Pyrouge 指向官方 rouge 脚本
pyrouge_set_rouge_path ~/pyrouge/rouge/tools/ROUGE-1.5.5/
给pyrouge的路径应该是绝对路径!
第 4 步:安装 libxml 解析器
如 this issue 中所述,你需要安装 libxml 解析器:
sudo apt-get install libxml-parser-perl
第 5 步:重新生成异常数据库
如 this issue 中所述,您需要重新生成异常数据库:
cd rouge/tools/ROUGE-1.5.5/data
rm WordNet-2.0.exc.db
./WordNet-2.0-Exceptions/buildExeptionDB.pl ./WordNet-2.0-Exceptions ./smart_common_words.txt ./WordNet-2.0.exc.db
第 6 步:运行测试
python -m pyrouge.test
你应该看到:
Ran 11 tests in 6.322s
OK
关于python - 安装pyrouge在ubuntu中出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45894212/