【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}")
相关推荐
渡我白衣40 分钟前
AI应用层革命(七)——智能体的终极形态:认知循环体的诞生
人工智能·深度学习·神经网络·目标检测·microsoft·机器学习·自然语言处理
workflower6 小时前
时序数据获取事件
开发语言·人工智能·python·深度学习·机器学习·结对编程
C++业余爱好者7 小时前
Java 提供了8种基本数据类型及封装类型介绍
java·开发语言·python
AI Echoes8 小时前
构建一个LangChain RAG应用
数据库·python·langchain·prompt·agent
派大鑫wink8 小时前
从零到精通:Python 系统学习指南(附实战与资源)
开发语言·python
c骑着乌龟追兔子8 小时前
Day 38 官方文档的阅读
python
羸弱的穷酸书生9 小时前
国网 i1协议 python实现
开发语言·python
weixin_462022359 小时前
RAW-Adapter: Adapting Pre-trained Visual Model to Camera RAW Images
python·计算机视觉
电子硬件笔记9 小时前
Python语言编程导论第三章 编写程序
开发语言·python·编辑器
布谷歌9 小时前
在java中实现c#的int.TryParse方法
java·开发语言·python·c#