我正在尝试安装 pyrouge,并且我运行了这段代码(在这个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)
但是我遇到了一些错误,回溯显示如下:
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'
这里的代码__init__.py
from pyrouge.base import Doc, Sent
from pyrouge.rouge import Rouge155
和被调用的函数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