Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in running example.py #11

Closed
jeremy-ying opened this issue Mar 29, 2017 · 12 comments
Closed

Error in running example.py #11

jeremy-ying opened this issue Mar 29, 2017 · 12 comments

Comments

@jeremy-ying
Copy link

Hi
I run the example.py, and I found this error:

evaluate sumamry & reference in these dir
summary: ./sample/summary/
reference: ./sample/reference/

All metric
Traceback (most recent call last):
File "example.py", line 16, in
setting_file = rouge.setting(files=True, summary_path=summary_dir, reference_path=reference_dir)
File "/home/yingwenhao/project/pythonrouge/pythonrouge/pythonrouge.py", line 107, in setting
file_name = os.path.splitext(os.path.basename(path))[0]
UnboundLocalError: local variable 'path' referenced before assignment

I checked the code, and I guess that something is ignored. How should I deal with the problem? thx

@PoppyLihhhh
Copy link

same problem

@PoppyLihhhh
Copy link

Have you resolve this issue??

@Yogayu
Copy link
Contributor

Yogayu commented May 22, 2017

The Path is wrong.
You can use the example in the README.

Notice that the ROUGE_path and the data_path should be your local path.

For example:

from pythonrouge.pythonrouge import Pythonrouge
#ROUGE-1.5.5.pl
ROUGE_path = "/Users/apple/scrapingEnv/pythonrouge/pythonrouge/RELEASE-1.5.5/ROUGE-1.5.5.pl"
#data folder in RELEASE-1.5.5
data_path = "/Users/apple/scrapingEnv/pythonrouge/pythonrouge/RELEASE-1.5.5/data"
# initialize setting of ROUGE, eval ROUGE-1, 2, SU4, L
rouge = Pythonrouge(n_gram=2, ROUGE_SU4=True, ROUGE_L=True, stemming=True, stopwords=True, word_level=True, length_limit=True, length=50, use_cf=False, cf=95, scoring_formula="average", resampling=True, samples=1000, favor=True, p=0.5)
# system summary & reference summary
# summary = [[" Tokyo is the one of the biggest city in the world."]]
# reference = [[["The capital of Japan, Tokyo, is the center of Japanese economy."]]]
summary = [["Great location, very good selection of food for breakfast buffet.",
            "Stunning food, amazing service.",
            "The food is excellent and the service great."],
            ["The keyboard, more than 90% standard size, is just large enough .",
            "Surprisingly readable screen for the size .",
            "Smaller size videos   play even smoother ."]]
reference = [[["Food was excellent with a wide range of choices and good services.", "It was a bit expensive though."],
           ["Food can be a little bit overpriced, but is good for a hotel."],
           ["The food in the hotel was a little over priced but excellent in taste and choice.",
           "There were also many choices to eat in the near vicinity of the hotel."],
           ["The food is good, the service great.",
           "Very good selection of food for breakfast buffet."]
           ],
           [
           ["The size is great and allows for excellent portability.",
           "Makes it exceptionally easy to tote around, and the keyboard is fairly big considering the size of this netbook."],
           ["Size is small and manageable.",
           "Perfect size and weight.",
           "Great size for travel."],
           ["The keyboard is a decent size, a bit smaller then average but good.",
           "The laptop itself is small but big enough do do things on it."],
           ["In spite of being small it is still comfortable.",
           "The screen and keyboard are well sized for use"]
           ]
           ]
# If you evaluate ROUGE by sentence list as above, set files=False
setting_file = rouge.setting(files=False, summary=summary, reference=reference)

# If you need only recall of ROUGE metrics, set recall_only=True
result = rouge.eval_rouge(setting_file, recall_only=False, ROUGE_path=ROUGE_path, data_path=data_path)
print(result)

@ghost
Copy link

ghost commented Jul 27, 2017

Hi @tagucci @Yogayu
I have set ROUGE_path and data_path properly already

ROUGE_path = r'C:\Downloads\ROUGE-1.5.5\ROUGE-1.5.5.pl'
data_path = r'C:\Downloads\ROUGE-1.5.5\data'

But I still got this error:

WindowsError                              Traceback (most recent call last)
<ipython-input-8-463accea89bc> in <module>()
     13 
     14 # If you need only recall of ROUGE metrics, set recall_only=True
---> 15 result = rouge.eval_rouge(setting_file, recall_only=True, ROUGE_path=ROUGE_path, data_path=data_path)
     16 print(result)

<ipython-input-5-f24a33cd5b51> in eval_rouge(self, xml_path, recall_only, f_measure_only, ROUGE_path, data_path)
    164         rouge_cmd.append(xml_path)
    165         print(rouge_cmd)
--> 166         output  = subprocess.check_output(rouge_cmd, stderr=subprocess.STDOUT)
    167         output  = output.decode("utf-8")
    168         outputs = output.strip().split("\n")

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 2] The system cannot find the file specified

Could you please help me with this issue? Thanks!

@ghost
Copy link

ghost commented Jul 27, 2017

When I tried it on centos, it returns this error:

subprocess.CalledProcessError: Command '['perl', '/home/gg/pythonrouge-master/pythonrouge/RELEASE-1.5.5/ROUGE-1.5.5.pl', '-e', '/home/gg/pythonrouge-master/pythonrouge/RELEASE-1.5.5/data', '-a', '-n', '2', '-2', '4', '-u', '-l', '50', '-m', '-s', '-f', 'A', '-r', '1000', '-p', '0.5', '/tmp/tmppT3n_b/setting.xml']' returned non-zero exit status 2

@rpanchal1996
Copy link

I had the same issue. Turns out I was missing a few perl based dependencies. You should just try running the ROUGE-1.5.5.pl script in your terminal by doing perl ROUGE-1.5.5.pl. Check for the errors, if any you may get and resolve the missing dependencies individually. I had a missing XML::Parser package. Installing it solved the problem.

@MahdiDoost
Copy link

MahdiDoost commented Sep 3, 2017

In the name of God

hello

I run example in windows 7.
`from pythonrouge.pythonrouge import Pythonrouge

ROUGE_path = 'D://MySoftWare/UniversitySoftWare/Term4/TS/Evaluate/pythonrouge-master/pythonrouge-master/pythonrouge/RELEASE-1.5.5/ROUGE-1.5.5.pl' #ROUGE-1.5.5.pl
data_path = 'D://MySoftWare/UniversitySoftWare/Term4/TS/Evaluate/pythonrouge-master/pythonrouge-master/pythonrouge/RELEASE-1.5.5/data' #data folder in RELEASE-1.5.5

rouge = Pythonrouge(n_gram=2, ROUGE_SU4=True, ROUGE_L=True, stemming=True, stopwords=True, word_level=True, length_limit=True, length=50, use_cf=False, cf=95, scoring_formula="average", resampling=True, samples=1000, favor=True, p=0.5)

summary = [[" Tokyo is the one of the biggest city in the world."]]
reference = [[["The capital of Japan, Tokyo, is the center of Japanese economy."]]]

setting_file = rouge.setting(files=False, summary=summary, reference=reference)

result = rouge.eval_rouge(setting_file, recall_only=True, ROUGE_path=ROUGE_path, data_path=data_path)
print(result)`

And get followed Error:
Traceback (most recent call last): File "D:\MySoftWare\UniversitySoftWare\Term4\MyProjectPython\RougeSample.py", line 17, in <module> result = rouge.eval_rouge(setting_file, recall_only=True, ROUGE_path=ROUGE_path, data_path=data_path) File "C:\Python 3 6 2\lib\site-packages\pythonrouge-0.3-py3.6.egg\pythonrouge\pythonrouge.py", line 166, in eval_rouge output = subprocess.check_output(rouge_cmd, stderr=subprocess.STDOUT) File "C:\Python 3 6 2\lib\subprocess.py", line 336, in check_output **kwargs).stdout File "C:\Python 3 6 2\lib\subprocess.py", line 418, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '['perl', 'D:\\MySoftWare\\UniversitySoftWare\\Term4\\TS\\Evaluate\\pythonrouge-master\\pythonrouge-master\\pythonrouge\\RELEASE-1.5.5\\ROUGE-1.5.5.pl', '-e', 'D:\\MySoftWare\\UniversitySoftWare\\Term4\\TS\\Evaluate\\pythonrouge-master\\pythonrouge-master\\pythonrouge\\RELEASE-1.5.5\\data', '-a', '-n', '2', '-2', '4', '-u', '-l', '50', '-m', '-s', '-f', 'A', '-r', '1000', '-p', '0.5', 'C:\\Users\\Amin\\AppData\\Local\\Temp\\tmp71ki_b6z\\setting.xml']' returned non-zero exit status 2.

Do the library run in windows?
thank you

@rpanchal1996
Copy link

Like I said, try to run the perl script from the command line directly, and not via the pythonrouge package. You will come to know if you have any perl related issues (missing dependencies, path etc).

@MahdiDoost
Copy link

In the name of God
hello
thank you for your answer

I do it and get followed Error:
Can 't locate DB_File.pm in @INC (you may need to install the DB_File module)

I install Active Perl 5.24 for install DB_File and I type ppm install DB_File in cmd of window 7.
Error is:
No missing packages to install.

Is there DB_File for windows?
Thank you

@MahdiDoost
Copy link

In the name of God
Hi,
Is pythonrouge suitable for utf_8?
Thank you

@MahdiDoost
Copy link

In the name of god
hello
I run sample and give me Error:

Traceback (most recent call last):
  File "/media/aliasghar/01CDBF1969EE87A0/MySoftWare/UniversitySoftWare/Term4/MyProjectPython/RougeSample.py", line 18, in <module>
    result = rouge.eval_rouge(setting_file, recall_only=True, ROUGE_path=ROUGE_path, data_path=data_path)
  File "/usr/local/lib/python3.5/dist-packages/pythonrouge/pythonrouge.py", line 166, in eval_rouge
    output  = subprocess.check_output(rouge_cmd, stderr=subprocess.STDOUT)
  File "/usr/lib/python3.5/subprocess.py", line 316, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.5/subprocess.py", line 398, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['perl', '/media/aliasghar/01CDBF1969EE87A0/MySoftWare/UniversitySoftWare/Term4/TS/Evaluate/pythonrouge-master/pythonrouge-master/pythonrouge/RELEASE-1.5.5/ROUGE-1.5.5.pl', '-e', '/media/aliasghar/01CDBF1969EE87A0/MySoftWare/UniversitySoftWare/Term4/TS/Evaluate/pythonrouge-master/pythonrouge-master/pythonrouge/RELEASE-1.5.5/data', '-a', '-n', '2', '-2', '4', '-u', '-l', '50', '-m', '-s', '-f', 'A', '-r', '1000', '-p', '0.5', '/tmp/tmp3tdl6l2z/setting.xml']' returned non-zero exit status 255

Like I said, try to run the perl script from the command line directly, and not via the pythonrouge package. You will come to know if you have any perl related issues (missing dependencies, path etc).

I run ROUGE-1.5.5.pl in terminal in linux with typing perl ROUGE-1.5.5.pl and get followed text:

ROUGE-1.5.5.pl
         [-a (evaluate all systems)] 
         [-c cf]
         [-d (print per evaluation scores)] 
         [-e ROUGE_EVAL_HOME] 
         [-h (usage)] 
         [-H (detailed usage)] 
         [-b n-bytes|-l n-words] 
         [-m (use Porter stemmer)] 
         [-n max-ngram] 
         [-s (remove stopwords)] 
         [-r number-of-samples (for resampling)] 
         [-2 max-gap-length (if < 0 then no gap length limit)] 
         [-3 <H|HM|HMR|HM1|HMR1|HMR2> (for scoring based on BE)] 
         [-u (include unigram in skip-bigram) default no)] 
         [-U (same as -u but also compute regular skip-bigram)] 
         [-w weight (weighting factor for WLCS)] 
         [-v (verbose)] 
         [-x (do not calculate ROUGE-L)] 
         [-f A|B (scoring formula)] 
         [-p alpha (0 <= alpha <=1)] 
         [-t 0|1|2 (count by token instead of sentence)] 
         [-z <SEE|SPL|ISI|SIMPLE>] 
         <ROUGE-eval-config-file> [<systemID>]

thank you

@MahdiDoost
Copy link

In The name of GOD
hello,
I do two tasks:

  1. I install XML::DOM with typing cpan XML::DOM in terminal.
    Then I run rouge 1.5.5 and I get following Error:
    Cannot open exception db file for reading: /home/pythonrouge/pythonrouge/RELEASE-1.5.5/data/WordNet-2.0.exc.db
    I create a new WordNet-2.0.exc.db by running the buildExceptionDB.pl script in the "data/WordNet-2.0-Exceptions" subdirectory.

2.I use from "https://libraries.io/github/tagucci/pythonrouge"

cd pythonrouge/RELEASE-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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants