【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}")
相关推荐
流水落花春去也1 分钟前
用yolov8 训练,最后形成训练好的文件。 并且能在后续项目使用
python
Serendipity_Carl3 分钟前
数据可视化实战之链家
python·数据可视化·数据清洗
小裴(碎碎念版)28 分钟前
文件读写常用操作
开发语言·爬虫·python
TextIn智能文档云平台32 分钟前
图片转文字后怎么输入大模型处理
前端·人工智能·python
Rabbit_QL33 分钟前
【LLM基础教程】语言模型基础
人工智能·语言模型·自然语言处理
ujainu44 分钟前
Python学习第一天:保留字和标识符
python·学习·标识符·保留字
studytosky1 小时前
深度学习理论与实战:反向传播、参数初始化与优化算法全解析
人工智能·python·深度学习·算法·分类·matplotlib
清水白石0081 小时前
《Python × 数据库:用 SQLAlchemy 解锁高效 ORM 编程的艺术》
开发语言·python·json
星依网络2 小时前
使用LabelImg工具标注数据(游戏辅助脚本开发)
python·游戏引擎·图形渲染·骨骼绑定
站大爷IP2 小时前
Appium实现Android应用数据爬取:从环境搭建到实战优化
python