【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}")
相关推荐
大模型码小白4 小时前
【Python零基础教程】继承、多态与魔法函数:面向对象编程三大核心特性详解
java·大数据·开发语言·人工智能·python·ai编程
麻雀飞吧5 小时前
最新量化学习路径,交易认知和技术实现要并行
人工智能·python
C^h9 小时前
python函数学习
人工智能·python·机器学习
KAU的云实验台9 小时前
【研究分享】大语言模型 × 进化计算新范式? —— 以ReEvo为例拆解
人工智能·语言模型·自然语言处理
Fanta丶9 小时前
4.Python set()集合、dict(字典、映射)、 数据容器的通用功能
python
决战灬9 小时前
langgraph之interrupt(理论篇)
人工智能·python·agent
兜客互动9 小时前
2026年AI关键词拓展挖掘软件,高效助力内容创作精准获流
人工智能·python
weixin_538601979 小时前
智能体测开Day30pytest测试框架
python
MC皮蛋侠客9 小时前
uv 系列(七):CI/CD、Docker 与私有索引——生产级交付
python·ci/cd·docker·uv
邪神与厨二病10 小时前
牛客周赛 Round 153
python·算法