跳转到主要内容

简单的Python文本处理。情感分析、词性标注、名词短语解析等。

项目描述

Latest version Build status

主页:https://textblob.readthedocs.io/

TextBlob 是一个用于处理文本数据的Python库。它提供了一个简单的API,用于执行常见的自然语言处理(NLP)任务,如词性标注、名词短语提取、情感分析、分类、翻译等。

from textblob import TextBlob

text = """
The titular threat of The Blob has always struck me as the ultimate movie
monster: an insatiably hungry, amoeba-like mass able to penetrate
virtually any safeguard, capable of--as a doomed doctor chillingly
describes it--"assimilating flesh on contact.
Snide comparisons to gelatin be damned, it's a concept with the most
devastating of potential consequences, not unlike the grey goo scenario
proposed by technological theorists fearful of
artificial intelligence run rampant.
"""

blob = TextBlob(text)
blob.tags  # [('The', 'DT'), ('titular', 'JJ'),
#  ('threat', 'NN'), ('of', 'IN'), ...]

blob.noun_phrases  # WordList(['titular threat', 'blob',
#            'ultimate movie monster',
#            'amoeba-like mass', ...])

for sentence in blob.sentences:
    print(sentence.sentiment.polarity)
# 0.060
# -0.341

TextBlob建立在NLTKpattern 之上,并且与它们都很好地兼容。

功能

  • 名词短语提取

  • 词性标注

  • 情感分析

  • 分类(朴素贝叶斯、决策树)

  • 分词(将文本分割成单词和句子)

  • 单词和短语频率

  • 解析

  • n-gram

  • 单词屈折(复数化和单数化)和词干化

  • 拼写校正

  • 通过扩展添加新模型或语言

  • WordNet集成

现在就获取它

$ pip install -U textblob
$ python -m textblob.download_corpora

示例

更多示例请参阅快速入门指南

文档

完整文档可在https://textblob.readthedocs.io/找到。

许可协议

MIT 许可。有关更多详细信息,请参阅捆绑的 LICENSE 文件。

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源分布

textblob-0.18.0.post0.tar.gz (639.6 kB 查看哈希值)

上传时间

构建分布

textblob-0.18.0.post0-py3-none-any.whl (626.3 kB 查看哈希值)

上传时间 Python 3

由以下机构支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页