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

pip install -U nltk rouge jieba

# Rouge

python 复制代码
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分词

python 复制代码
import jieba


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

print("分词结果:", seg_list)

# Bleu

python 复制代码
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}")
相关推荐
Learn Beyond Limits29 分钟前
Correlation vs Cosine vs Euclidean Distance|相关性vs余弦相似度vs欧氏距离
人工智能·python·神经网络·机器学习·ai·数据挖掘
专注于大数据技术栈30 分钟前
java学习--==和equals
java·python·学习
testtraveler2 小时前
[Fix] ImportError: libtorch_cpu.so: undefined symbol: iJIT_NotifyEvent
pytorch·python·bug
lang201509282 小时前
Kafka延迟操作机制深度解析
分布式·python·kafka
测试老哥3 小时前
软件测试:测试用例的设计
自动化测试·软件测试·python·功能测试·测试工具·职场和发展·测试用例
koo3644 小时前
pytorch环境配置
人工智能·pytorch·python
程序员杰哥7 小时前
Python自动化测试之线上流量回放:录制、打标、压测与平台选择
自动化测试·软件测试·python·测试工具·职场和发展·测试用例·压力测试
吴佳浩7 小时前
LangChain v1 重大更新讲解⚠⚠⚠
python·langchain·agent
顾安r9 小时前
11.20 开源APP
服务器·前端·javascript·python·css3
D***t1319 小时前
DeepSeek模型在自然语言处理中的创新应用
人工智能·自然语言处理