我试图使用https://github.com/boudinfl/pke模块提取关键短语。当我运行它一次它完美地工作。但是当我多次运行它时,它会发出以下错误。ZeroDivisionError:浮点除以零
我的代码如下。
extractor = TopicRank()
def key_phrase_extract(path_to_json):
//get_temp_text.txt from json
extractor.load_document(input='temp_text.txt', language="en", max_length=10000000,
normalization='stemming')
extractor.candidate_selection(pos={'NOUN', 'PROPN', 'ADJ'},stoplist=stoplist)
extractor.candidate_weighting(threshold=0.74,
method='average')
kpe_results = []
for (keyphrase, score) in extractor.get_n_best(n=10, stemming=True):
kpe_results.append([keyphrase, score])
print(kpe_results)
for each_json in json_list()
key_phrase_extract('each_json')
它为第一个 json 文件完美运行,但是在启动第二个文件时它给了我
ZeroDivisionError: float division by zero