微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

TextBlob 简易 Pythonic 文本处理工具

程序名称:TextBlob

授权协议: MIT

操作系统: 跨平台

开发语言: Python

TextBlob 介绍

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

特性:

  • 名词短语提取

  • 词性标记

  • 情绪分析

  • 分类

  • 由 Google 翻译提供的翻译和检测

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

  • 词句、短语频率

  • 解析

  • n-gram

  • 词变化(复数和单数化)和词形化

  • 拼写校正

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

  • WordNet 集成

示例:

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

blob.translate(to="es")  # 'La amenaza titular de The Blob...'

TextBlob 官网

https://github.com/sloria/TextBlob

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐