天天看点

三种rouge测评方法

1. 坑爹的rouge安装

2. rouge4chinese(不用安装,拿来直接用,中文)

https://github.com/hpzhao/nlp-metrics/tree/master/ROUGE4Chinese

3. sumeval(安装很简单,安完直接用,英文)

https://github.com/chakki-works/sumeval

我的使用过程:

1)安装:pip install sumeval

2)代码使用:

from sumeval.metrics.rouge import RougeCalculator


rouge = RougeCalculator(stopwords=True, )

rouge_1 = rouge.rouge_n(
            summary="I went to the Mars from my living town.",
            references="I went to Mars",
            n=1)

rouge_2 = rouge.rouge_n(
            summary="I went to the Mars from my living town.",
            references=["I went to Mars", "It's my living town"],
            n=2)

rouge_l = rouge.rouge_l(
            summary="I went to the Mars from my living town.",
            references=["I went to Mars", "It's my living town"])