Skip to main content

Simple, Pythonic text processing. Sentiment analysis, POS tagging, noun phrase parsing, and more.

Project description

TextBlob: Simplified Text Processing

Travis-CI Number of PyPI downloads

Homepage: https://textblob.readthedocs.org/

TextBlob is a Python (2 and 3) library for processing textual data. It provides a consistent API for diving into common natural language processing (NLP) tasks such as part-of-speech tagging, noun phrase extraction, sentiment analysis, and more.

from text.blob 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.pos_tags       # [(u'The', u'DT'), (u'titular', u'JJ'),
                    #  (u'threat', u'NN'), (u'of', u'IN'), ...]

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

for sentence in blob.sentences:
    print(blob.sentiment)  # returns (sentiment, subjectivity)
# (0.060, 0.605)
# (-0.34, 0.77)

Get it now

$ pip install -U textblob
$ curl https://raw.github.com/sloria/TextBlob/master/download_corpora.py | python

Examples

See more examples at the quickstart guide.

Documentation

Hosted here at ReadTheDocs.

Requirements

  • Python >= 2.6 or >= 3.3

Testing

Run

python run_tests.py

to run all tests.

License

TextBlob is licenced under the MIT license. See the bundled LICENSE file for more details.

Changelog

0.4.0 (2013-08-05)

  • New text.tokenizers module with WordTokenizer and SentenceTokenizer. Tokenizer instances (from either textblob itself or NLTK) can be passed to TextBlob’s constructor. Tokens are accessed through the new tokens property.

  • New Blobber class for creating TextBlobs that share the same tagger, tokenizer, and np_extractor.

  • Add ngrams method.

  • Backwards-incompatible: TextBlob.json() is now a method, not a property. This allows you to pass arguments (the same that you would pass to json.dumps()).

  • New home for documentation: https://textblob.readthedocs.org/

  • Add parameter for cleaning HTML markup from text.

  • Minor improvement to word tokenization.

  • Updated NLTK.

  • Fix bug with adding blobs to bytestrings.

0.3.10 (2013-08-02)

  • Bundled NLTK no longer overrides local installation.

  • Fix sentiment analysis of text with non-ascii characters.

0.3.9 (2013-07-31)

  • Updated nltk.

  • ConllExtractor is now Python 3-compatible.

  • Improved sentiment analysis.

  • Blobs are equal (with ==) to their string counterparts.

  • Added instructions to install textblob without nltk bundled.

  • Dropping official 3.1 and 3.2 support.

0.3.8 (2013-07-30)

  • Importing TextBlob is now much faster. This is because the noun phrase parsers are trained only on the first call to noun_phrases (instead of training them every time you import TextBlob).

  • Add text.taggers module which allows user to change which POS tagger implementation to use. Currently supports PatternTagger and NLTKTagger (NLTKTagger only works with Python 2).

  • NPExtractor and Tagger objects can be passed to TextBlob’s constructor.

  • Fix bug with POS-tagger not tagging one-letter words.

  • Rename text/np_extractor.py -> text/np_extractors.py

  • Add run_tests.py script.

0.3.7 (2013-07-28)

  • Every word in a Blob or Sentence is a Word instance which has methods for inflection, e.g word.pluralize() and word.singularize().

  • Updated the np_extractor module. Now has an new implementation, ConllExtractor that uses the Conll2000 chunking corpus. Only works on Py2.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

textblob-0.4.0.tar.gz (1.7 MB view details)

Uploaded Source

Built Distribution

textblob-0.4.0-py2.py3-none-any.whl (1.4 MB view details)

Uploaded Python 2 Python 3

File details

Details for the file textblob-0.4.0.tar.gz.

File metadata

  • Download URL: textblob-0.4.0.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for textblob-0.4.0.tar.gz
Algorithm Hash digest
SHA256 d9df348299d6b7de12bfcfc6a4f6c398ac5602f4bd8cd281d1928aa5b126838a
MD5 3888cffba4460042cd3ab63a6d67acf8
BLAKE2b-256 5d72fb80381c1afb1c53b8bede5705aff41fbf378b1be8d09ed871ebbc059b5e

See more details on using hashes here.

File details

Details for the file textblob-0.4.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for textblob-0.4.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7480cacdc2fc5c5571205e5bab7460b188f14253fe23fdb022b2ebf7b24774df
MD5 389b218c9b0b6e7df60e358711d9472f
BLAKE2b-256 09d993ca7828beda51711e5e4c90633d893aaa8e54a309a434707e8516223e7b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page