尝试运行pyrouge时出现“ FileNotFoundError”

时间:2019-06-18 13:27:06

标签: python windows nlp summarization

一段时间以来,我一直在尝试安装Python软件包 pyrouge 。最后,按照我安装的所有这些步骤here进行操作。到目前为止,这是与pyrouge相关的最有用的答案。它没有任何错误,我可以成功导入Rouge155。但是,当我尝试执行与步骤8中相同的测试(使用相同的代码)时,得到了FileNotFoundError。我将答案中的给定输出与我的输出进行了比较,我认为找不到文件“ rouge_conf.xml”。我检查,文件已创建。由于我的代表人数不足,因此无法提出评论,因此,我必须打开一个新问题。您知道确切的问题是什么,以及如何解决? (win10,python 3.7)。在此先感谢您的帮助。

这是我得到的错误(您可以与链接进行比较):

2019-06-18 21:14:14,361 [MainThread  ] [INFO ]  Writing summaries.
2019-06-18 21:14:14,362 [MainThread  ] [INFO ]  Processing summaries. Saving system files to C:\Users\admin\AppData\Local\Temp\tmp86sm5x3u\system and model files to C:\Users\admin\AppData\Local\Temp\tmp86sm5x3u\model.
2019-06-18 21:14:14,363 [MainThread  ] [INFO ]  Processing files in systems.
2019-06-18 21:14:14,363 [MainThread  ] [INFO ]  Processing text.001.txt.
2019-06-18 21:14:14,365 [MainThread  ] [INFO ]  Saved processed files to C:\Users\admin\AppData\Local\Temp\tmp86sm5x3u\system.
2019-06-18 21:14:14,366 [MainThread  ] [INFO ]  Processing files in references.
2019-06-18 21:14:14,367 [MainThread  ] [INFO ]  Processing text.A.001.txt.
2019-06-18 21:14:14,369 [MainThread  ] [INFO ]  Saved processed files to C:\Users\admin\AppData\Local\Temp\tmp86sm5x3u\model.
2019-06-18 21:14:14,374 [MainThread  ] [INFO ]  Written ROUGE configuration to C:\Users\admin\AppData\Local\Temp\tmpirzhwufa\rouge_conf.xml
2019-06-18 21:14:14,374 [MainThread  ] [INFO ]  Running ROUGE with command perl  D:\study\ROUGE-1.5.5\ROUGE-1.5.5.pl -e D:\study\ROUGE-1.5.5\data -c 95 -2 -1 -U -r 1000 -n 4 -w 1.2 -a -m C:\Users\admin\AppData\Local\Temp\tmpirzhwufa\rouge_conf.xml
Traceback (most recent call last):

  File "<ipython-input-21-732ec1e402fb>", line 1, in <module>
    runfile('C:/Users/admin/Desktop/somefolder/untitled0.py', wdir='C:/Users/admin/Desktop/somefolder')

  File "C:\Users\admin\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
    execfile(filename, namespace)

  File "C:\Users\admin\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/admin/Desktop/somefolder/untitled0.py", line 16, in <module>
    output = r.convert_and_evaluate()

  File "C:\Users\admin\Anaconda3\lib\site-packages\pyrouge-0.1.3-py3.7.egg\pyrouge\Rouge155.py", line 368, in convert_and_evaluate
    rouge_output = self.evaluate(system_id, rouge_args)

  File "C:\Users\admin\Anaconda3\lib\site-packages\pyrouge-0.1.3-py3.7.egg\pyrouge\Rouge155.py", line 343, in evaluate
    rouge_output = check_output(command, env=env).decode("UTF-8")

  File "C:\Users\admin\Anaconda3\lib\subprocess.py", line 395, in check_output
    **kwargs).stdout

  File "C:\Users\admin\Anaconda3\lib\subprocess.py", line 472, in run
    with Popen(*popenargs, **kwargs) as process:

  File "C:\Users\admin\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 143, in __init__
    super(SubprocessPopen, self).__init__(*args, **kwargs)

  File "C:\Users\admin\Anaconda3\lib\subprocess.py", line 775, in __init__
    restore_signals, start_new_session)

  File "C:\Users\admin\Anaconda3\lib\subprocess.py", line 1178, in _execute_child
    startupinfo)

FileNotFoundError: [WinError 2] The system cannot find the file specified 

编辑:今天,我再次运行了相同的代码,很奇怪,错误更改为CalledProcessError。写入here的错误相同。输出如下:

2019-06-19 16:00:15,115 [MainThread  ] [INFO ]  Writing summaries.
... The same as the first one...
2019-06-19 16:00:15,129 [MainThread  ] [INFO ]  Running ROUGE with command perl  D:\study\ROUGE-1.5.5\ROUGE-1.5.5.pl -e D:\study\ROUGE-1.5.5\data -c 95 -2 -1 -U -r 1000 -n 4 -w 1.2 -a -m C:\Users\admin\AppData\Local\Temp\tmpgyd8zauc\rouge_conf.xml
Traceback (most recent call last):

  File "<ipython-input-2-732ec1e402fb>", line 1, in <module>
    runfile('C:/Users/admin/Desktop/somefolder/untitled0.py', wdir='C:/Users/admin/Desktop/somefolder')

  File "C:\Users\admin\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
    execfile(filename, namespace)

  File "C:\Users\admin\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/admin/Desktop/somefolder/untitled0.py", line 16, in <module>
    output = r.convert_and_evaluate()

  File "C:\Users\admin\Anaconda3\lib\site-packages\pyrouge-0.1.3-py3.7.egg\pyrouge\Rouge155.py", line 368, in convert_and_evaluate
    rouge_output = self.evaluate(system_id, rouge_args)

  File "C:\Users\admin\Anaconda3\lib\site-packages\pyrouge-0.1.3-py3.7.egg\pyrouge\Rouge155.py", line 343, in evaluate
    rouge_output = check_output(command, env=env).decode("UTF-8")

  File "C:\Users\admin\Anaconda3\lib\subprocess.py", line 395, in check_output
    **kwargs).stdout

  File "C:\Users\admin\Anaconda3\lib\subprocess.py", line 487, in run
    output=stdout, stderr=stderr)

CalledProcessError: Command '['perl ', 'D:\\study\\ROUGE-1.5.5\\ROUGE-1.5.5.pl', '-e', 'D:\\study\\ROUGE-1.5.5\\data', '-c', '95', '-2', '-1', '-U', '-r', '1000', '-n', '4', '-w', '1.2', '-a', '-m', 'C:\\Users\\admin\\AppData\\Local\\Temp\\tmpgyd8zauc\\rouge_conf.xml']' returned non-zero exit status 255.

1 个答案:

答案 0 :(得分:0)

我有一个类似的问题。如果路径设置不正确,则会导致第一个错误。

  

D:\ study \ ROUGE-1.5.5 \ ROUGE-1.5.5.pl -e D:\ study \ ROUGE-1.5.5 \ data -c 95 -2 -1 -U -r 1000 -n 4 -w 1.2 -a -m C:\ Users \ admin \ AppData \ Local \ Temp \ tmpirzhwufa \ rouge_conf.xml

确保将胭脂路径添加到环境变量中,并且cmd / terminal可以识别该路径。

第二个错误可能是由于解码/参考语句格式方面的某些错误。句子必须在单独的行中。您可以在已保存的temp目录中检查已处理的输出。它必须具有以下结构:

<html>
<head>
<title>dummy title</title>
</head>
<body bgcolor="white">
<a name="1">[1]</a> <a href="#1" id=1>sentence 1</a>
<a name="2">[2]</a> <a href="#2" id=2>sentence 2</a>
</body>
</html>