【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}")
相关推荐
2401_894241921 天前
用Pygame开发你的第一个小游戏
jvm·数据库·python
一个帅气昵称啊1 天前
基于.NET AgentFramework开发OpenClaw智能体框架
人工智能·自然语言处理·c#·.net·openclaw
Zzzz_my1 天前
正则表达式(RE)
pytorch·python·正则表达式
天天鸭1 天前
前端仔写了个 AI Agent,才发现大模型只干了 10% 的活
前端·python·ai编程
setmoon2141 天前
使用Scikit-learn构建你的第一个机器学习模型
jvm·数据库·python
2401_833197731 天前
为你的Python脚本添加图形界面(GUI)
jvm·数据库·python
敏编程1 天前
一天一个Python库:tomlkit - 轻松解析和操作TOML配置
python
2401_879693871 天前
使用Python进行图像识别:CNN卷积神经网络实战
jvm·数据库·python
yunyun321231 天前
机器学习模型部署:将模型转化为Web API
jvm·数据库·python
柯儿的天空1 天前
Mem0深度解析:给你的ai agent加上长期记忆,让ai从“健忘“到“过目不忘“
人工智能·gpt·自然语言处理·ai作画·aigc·ai编程·agi