欢乐狗 发表于 2024-11-8 10:38:14

【python ROUGE BLEU jiaba.cut NLP常用的指标盘算】

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 https://i-blog.csdnimg.cn/direct/5782355e83a84d57ba657893eee28106.png

# jieba分词

import jieba


text = "我爱自然语言处理"
seg_list = list(jieba.cut(text, cut_all=False))

print("分词结果:", seg_list) https://i-blog.csdnimg.cn/direct/7df98fc7f03e4599a4895135ce28ac34.png
# 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}") https://i-blog.csdnimg.cn/direct/240ca82f994b4623bba6876645ae4f47.png



免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: 【python ROUGE BLEU jiaba.cut NLP常用的指标盘算】