danieldeutsch / sacrerouge

SacreROUGE is a library dedicated to the use and development of text generation evaluation metrics with an emphasis on summarization.
Apache License 2.0
134 stars 11 forks source link

Rouge-L in python interface? #131

Open serenayj opened 2 years ago

serenayj commented 2 years ago

Hi Daniel,

Kudos to the wonderful pacakge! I wonder how to use Rouge-L under the python interface, i.e. the example you shown in the tutorial. Thanks!

danieldeutsch commented 2 years ago

Hi Yanjun,

There are two versions of ROUGE, one which is a wrapper around the original Perl implementation and one which is written (by me) in Python.

For the Perl version:

from sacrerouge.metrics import Rouge
metric = Rouge(compute_rouge_l=True)
results = metric.score("The summary to score", ["The list of references"])

There are different methods for scoring depending on whether you have multiple summaries, etc. The information is here.

The Python version is basically identical, except there's a different class you use:

from sacrerouge.metrics import PythonRouge
metric = PythonRouge(compute_rouge_l=True)

It has the same scoring functions as the Perl version.

Hope this helps!