Easy sentiment analysis for spaCy using TextBlob. Now supports spaCy 3.0!

spaCyTextBlob is a pipeline component that enables sentiment analysis using the TextBlob library. It will add the additional extensions ._.polarity, ._.subjectivity, and ._.assessments to Doc, Span, and Token objects. For spaCy 2 please use pip install pip install spacytextblob==0.1.7


import spacy from spacytextblob.spacytextblob import SpacyTextBlob nlp = spacy.load('en_core_web_sm') nlp.add_pipe('spacytextblob') text = 'I had a really horrible day. It was the worst day ever! But every now and then I have a really good day that makes me happy.' doc = nlp(text) doc._.polarity # Polarity: -0.125 doc._.subjectivity # Sujectivity: 0.9 doc._.assessments # Assessments: [(['really', 'horrible'], -1.0, 1.0, None), (['worst', '!'], -1.0, 1.0, None), (['really', 'good'], 0.7, 0.6000000000000001, None), (['happy'], 0.8, 1.0, None)]
View more
Author info

Sam Edwardes


Categories pipeline

Submit your project

If you have a project that you want the spaCy community to make use of, you can suggest it by submitting a pull request to the spaCy website repository. The Universe database is open-source and collected in a simple JSON file. For more details on the formats and available fields, see the documentation. Looking for inspiration your own spaCy plugin or extension? Check out the project idea label on the issue tracker.

Read the docsJSON source