pip install -U nltk rouge jieba
# Rouge
- from rouge import Rouge
- rouge = Rouge()
- reference = "The quick brown fox jumps over the lazy dog"
- candidate = "The quick brown fox jumps over the dog"
- scores = rouge.get_scores(candidate, reference)
- scores
复制代码
# jieba分词
- import jieba
- text = "我爱自然语言处理"
- seg_list = list(jieba.cut(text, cut_all=False))
- print("分词结果:", seg_list)
复制代码
# Bleu
- from nltk.translate.bleu_score import sentence_bleu
- candidates = ["this", "is", "a", "test"]
- references = [["this", "is", "a", "test"]]
- bleu_score = sentence_bleu(references, candidates)
- print(f"Corpus BLEU Score: {bleu_score}")
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |