1

i'm trying to install pyrouge, and i ran this code (following this repo)

from pyrouge import Rouge155
from pprint import pprint

ref_texts = {'A': "Poor nations pressurise developed countries into granting trade subsidies.",
             'B': "Developed countries should be pressurized. Business exemptions to poor nations.",
             'C': "World's poor decide to urge developed nations for business concessions."}
summary_text = "Poor nations demand trade subsidies from developed nations."


rouge = Rouge155(n_words=100)
score = rouge.score_summary(summary_text, ref_texts)
pprint(score)

But i got some error, the traceback displayed as below:

Traceback (most recent call last):

  File "<ipython-input-116-94aea372ee05>", line 1, in <module>
    runfile('C:/Users/cerdas/Documents/Bil/Lat/rouge.py', wdir='C:/Users/cerdas/Documents/Bil/Lat')

  File "C:\Users\cerdas\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
    execfile(filename, namespace)

  File "C:\Users\cerdas\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/cerdas/Documents/Bil/Lat/rouge.py", line 10, in <module>
    rouge = Rouge155(n_words=100)

TypeError: __init__() got an unexpected keyword argument 'n_words'

and here the code of __init__.py

from pyrouge.base import Doc, Sent
from pyrouge.rouge import Rouge155

and the called function Rouge155

class Rouge155(object):
    def __init__(self, rouge_home=ROUGE_EVAL_HOME, n_words=None, stem=False, keep_files=False):
        self._stem = stem
        self._n_words = n_words
        self._discover_rouge(rouge_home)
        self._keep_files = keep_files
Bily
  • 51
  • 9
  • 1
    What is n_words here for ? I don't see any reference to that in [here](https://pypi.org/project/pyrouge/#history) and [here](https://github.com/bheinzerling/pyrouge/blob/master/pyrouge/Rouge155.py) – Vineeth Sai Sep 14 '18 at 06:51
  • The code you show for `Rouge155` is completely different from the one in the github repository. – Thierry Lathuille Sep 14 '18 at 06:54
  • i following this [link](https://github.com/andersjo/pyrouge) code @VineethSai – Bily Sep 14 '18 at 06:55

3 Answers3

0

You need to export your environment variable: ROUGE_EVAL_HOME

From the docs:

Assuming a working ROUGE-1.5.5. installation, tell pyrouge the ROUGE path with this command:

pyrouge_set_rouge_path /absolute/path/to/ROUGE-1.5.5/directory

Community
  • 1
  • 1
Daniel Lee
  • 7,189
  • 2
  • 26
  • 44
  • Sorry, i didn't get what do you mean, i still have no idea how to solve it – Bily Sep 14 '18 at 07:08
  • You need to follow the instructions in the docs, if you have trouble with any steps, let me know. If you don't know how to export an environment variable, look it up for your os. – Daniel Lee Sep 14 '18 at 07:41
0

Go to your Repository (Your folder where you cloned this from). Now make your way into pyrouge/base.py and make sure the variable ROUGE_EVAL_HOME points to tools/ROUGE-1.5.5.Try entering the entire destination manually by copying the filepath and then if it works try using os module to make it more dynamic. You need to tell your code to point to the ROUGE package that is in your repository not the one you get from pip install pyrouge

Vineeth Sai
  • 3,389
  • 7
  • 23
  • 34
  • i've been changing the `ROUGE_EVAL_HOME` to my `ROUGE-1.5.5` directory as this code `ROUGE_EVAL_HOME = str(os.path.dirname("C:\\rouge\\tools\\ROUGE-1.5.5"))` is anything wrong? i still get the same error. Thx – Bily Sep 20 '18 at 05:10
0

The following instructions were tested on Windows 10 and python 3.7x32

Do download your project pyrouge on the repository of the Anders Johannsen. No install thought for pip install pyrouge.

To solve I had to make a small modification at the moment the command line is built that and will run ROUGE-1.5.5.pl. In windows, besides you need to add PERL.exe to the environment variables, but you will also need change the class Rouge155() in file code \pyrouge\rouge.py.

  1. Open the file code \pyrouge\rouge.py go to the function def _run_rouge(self) (it's at line 96 at the time I am writing this answer).
  2. Go to the line 122, comment this line return check_output([self._rouge_bin] + options)
  3. Add this code in place:
    command = [self._rouge_bin] + options
    command.insert(0, 'perl ')
    return check_output(command)

Franck Dernoncourt in your answer for the question How to install the Python package pyrouge on Microsoft Windows? solved the problem in the step 7, but this step only works in pyrouge installed through of the pip install rouge, in the implementation of repository of the other author, Benjamin Heinzerling.

And you are trying to use the version available the repository of the author Anders Johannsen. The his implementation has the class with the arguments you commented n_words=100, but only in the his version of the class Rouge155(), and her not in Python Package Index (PyPI).

P.S: Sorry for any mistake, my english is medium.

Blanda
  • 1
  • 2