【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}")
相关推荐
不爱吃鱼的猫-18 分钟前
PySide6控件:QFont设置、QColor调色板、QPixmap图像处理与QCursor光标自定义
python·pyqt·个人开发·pyside6
276695829228 分钟前
拼多多 anti-token unidbg 分析
java·python·go·拼多多·pdd·pxx·anti-token
我是个菜鸡.29 分钟前
Python-八股总结
开发语言·python
风暴之零35 分钟前
使用大语言模型进行Python图表可视化
人工智能·python·语言模型·数据可视化
安然无虞41 分钟前
31天Python入门——第17天:初识面向对象
后端·爬虫·python·职场和发展
程序员小远1 小时前
Python+requests实现接口自动化测试框架
自动化测试·软件测试·python·测试工具·职场和发展·测试用例·接口测试
A叶子叶1 小时前
Kong网关部署研究
python·spring cloud·微服务·gateway·kong
聪明的墨菲特i1 小时前
Python 办公技巧:PDF 自动化处理
python·pdf·自动化
Ronin-Lotus1 小时前
深度学习篇---模型参数调优
人工智能·pytorch·python·深度学习·paddlepaddle·batch·学习率
林泽毅2 小时前
SwanLab硬件监控:英伟达、昇腾、寒武纪
python·深度学习·昇腾·英伟达·swanlab·寒武纪·训练实战