【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}")
相关推荐
有风南来24 分钟前
算术图片验证码(四则运算)+selenium
自动化测试·python·selenium·算术图片验证码·四则运算验证码·加减乘除图片验证码
wangjinjin18024 分钟前
Python Excel 文件处理:openpyxl 与 pandas 库完全指南
开发语言·python
Yxh181377845541 小时前
抖去推--短视频矩阵系统源码开发
人工智能·python·矩阵
Humbunklung2 小时前
PySide6 GUI 学习笔记——常用类及控件使用方法(多行文本控件QTextEdit)
笔记·python·学习·pyqt
Jamence2 小时前
多模态大语言模型arxiv论文略读(111)
论文阅读·人工智能·语言模型·自然语言处理·论文笔记
火车叼位2 小时前
使用 uv 工具在 Windows 系统快速下载安装与切换 Python
python
心扬3 小时前
python网络编程
开发语言·网络·python·tcp/ip
忧陌6063 小时前
DAY 44 预训练模型
python
点云SLAM3 小时前
PyTorch 中contiguous函数使用详解和代码演示
人工智能·pytorch·python·3d深度学习·contiguous函数·张量内存布局优化·张量操作
小天才才3 小时前
【自然语言处理】大模型时代的数据标注(主动学习)
人工智能·机器学习·语言模型·自然语言处理