{"id":13827748,"url":"https://github.com/SamEdwardes/spacytextblob","last_synced_at":"2025-07-09T05:30:28.432Z","repository":{"id":43754630,"uuid":"311889150","full_name":"SamEdwardes/spacytextblob","owner":"SamEdwardes","description":"A TextBlob sentiment analysis pipeline component for spaCy.","archived":false,"fork":false,"pushed_at":"2024-10-12T20:19:27.000Z","size":860,"stargazers_count":54,"open_issues_count":5,"forks_count":8,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-14T14:55:20.354Z","etag":null,"topics":["natural-language-processing","nlp","python","spacy"],"latest_commit_sha":null,"homepage":"https://spacytextblob.netlify.app/","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SamEdwardes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-11T07:00:33.000Z","updated_at":"2024-10-12T20:18:32.000Z","dependencies_parsed_at":"2022-09-19T09:50:22.372Z","dependency_job_id":null,"html_url":"https://github.com/SamEdwardes/spacytextblob","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamEdwardes%2Fspacytextblob","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamEdwardes%2Fspacytextblob/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamEdwardes%2Fspacytextblob/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamEdwardes%2Fspacytextblob/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SamEdwardes","download_url":"https://codeload.github.com/SamEdwardes/spacytextblob/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225486430,"owners_count":17481900,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["natural-language-processing","nlp","python","spacy"],"created_at":"2024-08-04T09:02:06.906Z","updated_at":"2024-11-20T07:31:05.619Z","avatar_url":"https://github.com/SamEdwardes.png","language":"Jupyter Notebook","funding_links":[],"categories":["Jupyter Notebook"],"sub_categories":[],"readme":"# spacytextblob\n\n[![PyPI version](https://badge.fury.io/py/spacytextblob.svg)](https://badge.fury.io/py/spacytextblob)\n[![pytest](https://github.com/SamEdwardes/spacytextblob/actions/workflows/pytest.yml/badge.svg)](https://github.com/SamEdwardes/spacytextblob/actions/workflows/pytest.yml)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/spacytextblob?label=PyPi%20Downloads)\n[![Netlify Status](https://api.netlify.com/api/v1/badges/e2f2caac-7239-45a2-b145-a00205c3befb/deploy-status)](https://app.netlify.com/sites/spacytextblob/deploys)\n\nA TextBlob sentiment analysis pipeline component for spaCy. \n\n- [Docs](https://spacytextblob.netlify.app/)\n- [GitHub](https://github.com/SamEdwardes/spacytextblob)\n- [PyPi](https://pypi.org/project/spacytextblob/)\n- [spaCy Universe](https://spacy.io/universe/project/spacy-textblob)\n\n## Install\n\nInstall *spacytextblob* from PyPi.\n\n```bash\npip install spacytextblob\n```\n\nTextBlob requires additional data to be downloaded before getting started.\n\n```bash\npython -m textblob.download_corpora\n```\n\nspaCy also requires that you download a model to get started.\n\n```bash\npython -m spacy download en_core_web_sm\n```\n\n## Quick Start\n\n*spacytextblob* allows you to access all of the attributes created of the `textblob.TextBlob` class but within the spaCy framework. The code below will demonstrate how to use *spacytextblob* on a simple string.\n\n```python\nimport spacy\nfrom spacytextblob.spacytextblob import SpacyTextBlob\n\nnlp = spacy.load('en_core_web_sm')\ntext = \"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.\"\nnlp.add_pipe(\"spacytextblob\")\ndoc = nlp(text)\n\nprint(doc._.blob.polarity)\n# -0.125\n\nprint(doc._.blob.subjectivity)\n# 0.9\n\nprint(doc._.blob.sentiment_assessments.assessments)\n# [(['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)]\n```\n\nIn comparison, here is how the same code would look using `TextBlob`:\n\n```python\nfrom textblob import TextBlob\n\ntext = \"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.\"\nblob = TextBlob(text)\n\nprint(blob.sentiment_assessments.polarity)\n# -0.125\n\nprint(blob.sentiment_assessments.subjectivity)\n# 0.9\n\nprint(blob.sentiment_assessments.assessments)\n# [(['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)]\n```\n\n## Quick Reference\n\n*spacytextblob* performs sentiment analysis using the [TextBlob](https://textblob.readthedocs.io/en/dev/quickstart.html) library. Adding *spacytextblob* to a spaCy nlp pipeline creates a new extension attribute for the `Doc`, `Span`, and `Token` classes from spaCy.\n\n- `Doc._.blob`\n- `Span._.blob`\n- `Token._.blob`\n\nThe `._.blob` attribute contains all of the methods and attributes that belong to the `textblob.TextBlob` class Some of the common methods and attributes include: \n\n- **`._.blob.polarity`**: a float within the range [-1.0, 1.0].\n- **`._.blob.subjectivity`**: a float within the range [0.0, 1.0] where 0.0 is very objective and 1.0 is very subjective. \n- **`._.blob.sentiment_assessments.assessments`**: a list of polarity and subjectivity scores for the assessed tokens.\n\nSee the [textblob docs](https://textblob.readthedocs.io/en/dev/api_reference.html#textblob.blob.TextBlob) for the complete listing of all attributes and methods that are available in `._.blob`.\n\n## Reference and Attribution\n\n- TextBlob\n    - [https://github.com/sloria/TextBlob](https://github.com/sloria/TextBlob)\n    - [https://textblob.readthedocs.io/en/latest/](https://textblob.readthedocs.io/en/latest/)\n- negspaCy (for inspiration in writing pipeline and organizing repo)\n    - [https://github.com/jenojp/negspacy](https://github.com/jenojp/negspacy)\n- spaCy custom components\n    - [https://spacy.io/usage/processing-pipelines#custom-components](https://spacy.io/usage/processing-pipelines#custom-components)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSamEdwardes%2Fspacytextblob","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSamEdwardes%2Fspacytextblob","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSamEdwardes%2Fspacytextblob/lists"}