bheinzerling / pyrouge

A Python wrapper for the ROUGE summarization evaluation package
MIT License
250 stars 71 forks source link

WindowsError: [Error 193] %1 is not a valid Win32 application #9

Closed ghost closed 7 years ago

ghost commented 7 years ago
WindowsError                              Traceback (most recent call last)
<ipython-input-4-b6efe7b2e6d3> in <module>()
----> 1 rouge_eval('../Documents/rslt/cp/reference/', '../Documents/rslt/pg/decoded/')

<ipython-input-2-17db6565b0ff> in rouge_eval(ref_dir, dec_dir)
      7     r.system_dir = dec_dir
      8     logging.getLogger('global').setLevel(logging.WARNING) # silence pyrouge logging
----> 9     rouge_results = r.convert_and_evaluate()
     10     return r.output_to_dict(rouge_results)

C:\Anaconda\lib\site-packages\pyrouge-0.1.3-py2.7.egg\pyrouge\Rouge155.pyc in convert_and_evaluate(self, system_id, split_sentences, rouge_args)
    362             self.split_sentences()
    363         self.__write_summaries()
--> 364         rouge_output = self.evaluate(system_id, rouge_args)
    365         return rouge_output
    366 

C:\Anaconda\lib\site-packages\pyrouge-0.1.3-py2.7.egg\pyrouge\Rouge155.pyc in evaluate(self, system_id, rouge_args)
    337         self.log.info(
    338             "Running ROUGE with command {}".format(" ".join(command)))
--> 339         rouge_output = check_output(command).decode("UTF-8")
    340         return rouge_output
    341 

C:\Anaconda\lib\subprocess.pyc in check_output(*popenargs, **kwargs)
    565     if 'stdout' in kwargs:
    566         raise ValueError('stdout argument not allowed, it will be overridden.')
--> 567     process = Popen(stdout=PIPE, *popenargs, **kwargs)
    568     output, unused_err = process.communicate()
    569     retcode = process.poll()

C:\Anaconda\lib\subprocess.pyc in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags)
    709                                 p2cread, p2cwrite,
    710                                 c2pread, c2pwrite,
--> 711                                 errread, errwrite)
    712         except Exception:
    713             # Preserve original exception in case os.close raises.

C:\Anaconda\lib\subprocess.pyc in _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, to_close, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite)
    957                                          env,
    958                                          cwd,
--> 959                                          startupinfo)
    960             except pywintypes.error, e:
    961                 # Translate pywintypes.error to WindowsError, which is

WindowsError: [Error 193] %1 is not a valid Win32 application
bheinzerling commented 7 years ago

It looks like pyrouge generated all the files necessary for running ROUGE, but the actual command for running it fails.

You can try running ROUGE manually, with this in a console:

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

If this fails, it means that Perl has probably not been installed correctly on your system. This is what you should see when you run the commands

assoc .pl type PerlScript

in a console:

C:>assoc .pl .pl=PerlScript

C:>ftype PerlScript PerlScript=C:\bin\perl.exe "%1" %*

If this works, then .py files may not have been correctly associated with python.exe on your system. You can check with this:

C:>assoc .py .py=Python.File

C:>ftype Python.File Python.File="C:\Python27\python.exe" "%1" %*

ghost commented 7 years ago

Thanks for you reply! I have installed perl properly. I wonder what is the input (system and model) command? And what is the proper format of the file? Same with the one of your code? Thx!

bheinzerling commented 7 years ago

Before the error happens, you should see something like this:

Running ROUGE with command ..\RELEASE-1.5.5\ROUGE-1.5.5.pl -e ...\RELEASE-1.5.5\data -c 95 -2 -1 -U -r 1000 -n 4 -w 1.2 -a -m C:\Users...\AppData\Local\Temp\tmpwbiw8z7b\rouge_conf.xml

This is the command pyrouge uses to call ROUGE (the paths will be different on your system).

You can run ROUGE manually by copy&pasting this command into a terminal and then see if this works or not.

ghost commented 7 years ago

So the rouge_conf contains the processed data?

ghost commented 7 years ago

@bheinzerling Sorry, I just found that the output of assoc .pl is good but the one of ftype PerlScript is File type 'PerlScript' not found or no open command associated with it. But I have downloaded and installed perl in a proper way. Why this happens?

bheinzerling commented 7 years ago

Something like this should work:

ftype PerlScript "C:\bin\perl.exe "%1" %*" (replace C:\bin\perl.exe with the perl.exe path on your system)