错误信息
rouge使用过程中,上报如下错误:
Cannot open :/root/ROUGE/RELEASE-1.5.5/data/smart_common_words.txt
定位分析
定位到出错的位置,ROUGE-1.5.5.pl文件第475行:
open(STOP,$stopwords)||die "Cannot open $stopwords\n";
结合错误信息,发现$stopwords变量多了一个 ': ’
文件中,变量的定义代码块为:
if(defined($opt_e)) {
$stopwords="$opt_e/smart_common_words.txt";
$wordnetDB="$opt_e/WordNet-2.0.exc.db";
}
else {
if(exists($ENV{"ROUGE_EVAL_HOME"})) {
$stopwords="$ENV{\"ROUGE_EVAL_HOME\"}/smart_common_words.txt";
$wordnetDB="$ENV{\"ROUGE_EVAL_HOME\"}/WordNet-2.0.exc.db";
}
elsif(exists($ENV{"RED_EVAL_HOME"})) {
$stopwords="$ENV{\"RED_EVAL_HOME\"}/smart_common_words.txt";
$wordnetDB="$ENV{\"RED_EVAL_HOME\"}/WordNet-2.0.exc.db";
}
else {
# if no environment variable exists then assume data files are in the current directory
$stopwords="smart_common_words.txt";
$wordnetDB="WordNet-2.0.exc.db";
}
}
我们添加的环境变量为:
export ROUGE_EVAL_HOME=$ROUGE_EVAL_HOME:/root/ROUGE/RELEASE-1.5.5/data
推测是perl在解析环境变量时出了问题,多解析了一个’:’。
解决方案
由于本人对perl语言不熟悉,只能从其它方面解决,目前只想到两种解决方式:
1,执行脚本ROUGE-1.5.5.pl 时,添加选项:
-e /root/ROUGE/RELEASE-1.5.5/data
2,将环境变量修改为
export ROUGE_EVAL_HOME=/root/ROUGE/RELEASE-1.5.5/data
rouge安装教程参考:
Ubuntu安装配置ROUGE