简介:
NLTK 是用于构建 Python 程序以处理人类语言数据的领先平台。它为超过 50 个语料库和词汇资源(如 WordNet)提供易于使用的接口,以及一套用于分类、标记化、词干提取、标记、解析和语义推理的文本处理库,工业级 NLP 库的包装器,和一个活跃的讨论论坛。
得益于介绍编程基础知识和计算语言学主题的实践指南,以及全面的 API 文档,NLTK 适合语言学家、工程师、学生、教育工作者、研究人员和行业用户。 NLTK 适用于 Windows、Mac OS X 和 Linux。最重要的是,NLTK 是一个免费、开源、社区驱动的项目。
NLTK 被称为“使用 Python 进行计算语言学教学和工作的绝佳工具”和“使用自然语言的惊人库”。
Example
Sample usage for bleu
from nltk.translate import bleu
from nltk.translate.bleu_score import sentence_bleu
# If the candidate has no alignment to any of the references, the BLEU score is 0.
bleu(['The candidate has no alignment to any of the references'.split()],
'John loves Mary'.split(),(1,))
# A Systematic Comparison of Smoothing Techniques for Sentence-Level BLEU的实现
sentence_bleu(['It is a place of quiet contemplation .'.split()],'It is .'.split(),
smoothing_function=SmoothingFunction().method4)*100
# bleu-4
candidate = 'wo zai qing hua gao zi ran yu yan chu li juhao'
reference = 'wo shi qing hua da xue zi ran yu yan chu li shi yan shi de tong xue juhao'
score = sentence_bleu([reference].split(), candidate.split())
参考:
NLTK是一个领先的Python平台,用于处理人类语言数据,提供丰富的语料库接口和文本处理库。它支持分类、标记化、词干提取等任务,适用于语言学家、工程师和研究人员。示例展示了如何使用NLTK计算BLEU分数,这是一个评估机器翻译质量的指标。NLTK可在多种操作系统上运行,并且是免费、开源的。
7万+






