spacytextblob


Namespacytextblob JSON
Version 5.0.0 PyPI version JSON
download
home_pageNone
SummaryA TextBlob sentiment analysis pipeline component for spaCy.
upload_time2024-10-12 20:19:46
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords nlp python spacy textblob
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # spacytextblob

[![PyPI version](https://badge.fury.io/py/spacytextblob.svg)](https://badge.fury.io/py/spacytextblob)
[![pytest](https://github.com/SamEdwardes/spacytextblob/actions/workflows/pytest.yml/badge.svg)](https://github.com/SamEdwardes/spacytextblob/actions/workflows/pytest.yml)
![PyPI - Downloads](https://img.shields.io/pypi/dm/spacytextblob?label=PyPi%20Downloads)
[![Netlify Status](https://api.netlify.com/api/v1/badges/e2f2caac-7239-45a2-b145-a00205c3befb/deploy-status)](https://app.netlify.com/sites/spacytextblob/deploys)

A TextBlob sentiment analysis pipeline component for spaCy. 

- [Docs](https://spacytextblob.netlify.app/)
- [GitHub](https://github.com/SamEdwardes/spacytextblob)
- [PyPi](https://pypi.org/project/spacytextblob/)
- [spaCy Universe](https://spacy.io/universe/project/spacy-textblob)

## Install

Install *spacytextblob* from PyPi.

```bash
pip install spacytextblob
```

TextBlob requires additional data to be downloaded before getting started.

```bash
python -m textblob.download_corpora
```

spaCy also requires that you download a model to get started.

```bash
python -m spacy download en_core_web_sm
```

## Quick Start

*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.

```python
import spacy
from spacytextblob.spacytextblob import SpacyTextBlob

nlp = spacy.load('en_core_web_sm')
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."
nlp.add_pipe("spacytextblob")
doc = nlp(text)

print(doc._.blob.polarity)
# -0.125

print(doc._.blob.subjectivity)
# 0.9

print(doc._.blob.sentiment_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)]
```

In comparison, here is how the same code would look using `TextBlob`:

```python
from textblob import TextBlob

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."
blob = TextBlob(text)

print(blob.sentiment_assessments.polarity)
# -0.125

print(blob.sentiment_assessments.subjectivity)
# 0.9

print(blob.sentiment_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)]
```

## Quick Reference

*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.

- `Doc._.blob`
- `Span._.blob`
- `Token._.blob`

The `._.blob` attribute contains all of the methods and attributes that belong to the `textblob.TextBlob` class Some of the common methods and attributes include: 

- **`._.blob.polarity`**: a float within the range [-1.0, 1.0].
- **`._.blob.subjectivity`**: a float within the range [0.0, 1.0] where 0.0 is very objective and 1.0 is very subjective. 
- **`._.blob.sentiment_assessments.assessments`**: a list of polarity and subjectivity scores for the assessed tokens.

See 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`.

## Reference and Attribution

- TextBlob
    - [https://github.com/sloria/TextBlob](https://github.com/sloria/TextBlob)
    - [https://textblob.readthedocs.io/en/latest/](https://textblob.readthedocs.io/en/latest/)
- negspaCy (for inspiration in writing pipeline and organizing repo)
    - [https://github.com/jenojp/negspacy](https://github.com/jenojp/negspacy)
- spaCy custom components
    - [https://spacy.io/usage/processing-pipelines#custom-components](https://spacy.io/usage/processing-pipelines#custom-components)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "spacytextblob",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "Sam Edwardes <edwardes.s@gmail.com>",
    "keywords": "nlp, python, spacy, textblob",
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/1c/25/7b1406a8b9465f2febf9b1ec4dfd7928405373685407a36dc1e19b94dc94/spacytextblob-5.0.0.tar.gz",
    "platform": null,
    "description": "# 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",
    "bugtrack_url": null,
    "license": null,
    "summary": "A TextBlob sentiment analysis pipeline component for spaCy.",
    "version": "5.0.0",
    "project_urls": {
        "Changelog": "https://github.com/SamEdwardes/spacytextblob/blob/main/docs/changelog.md",
        "Documentation": "https://spacytextblob.netlify.app/",
        "Homepage": "https://spacytextblob.netlify.app/",
        "Issues": "https://github.com/SamEdwardes/spacytextblob/issues",
        "Repository": "https://github.com/SamEdwardes/spacytextblob"
    },
    "split_keywords": [
        "nlp",
        " python",
        " spacy",
        " textblob"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b42f50045552f49b0fbb860852f733d9f94a7fe72cb2206a3e5ec7917c5ffd04",
                "md5": "78669c04b595f46304b0de6134012344",
                "sha256": "1c1a76bc4d6888093495a85df073c7f243c47265801acff92151b0749e086e0c"
            },
            "downloads": -1,
            "filename": "spacytextblob-5.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "78669c04b595f46304b0de6134012344",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 4186,
            "upload_time": "2024-10-12T20:19:45",
            "upload_time_iso_8601": "2024-10-12T20:19:45.356526Z",
            "url": "https://files.pythonhosted.org/packages/b4/2f/50045552f49b0fbb860852f733d9f94a7fe72cb2206a3e5ec7917c5ffd04/spacytextblob-5.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "1c257b1406a8b9465f2febf9b1ec4dfd7928405373685407a36dc1e19b94dc94",
                "md5": "ec06ceb766317458b32aa67a751374b2",
                "sha256": "4bd0a7c65a0144dd286d88fae4ee3ebf9a82c0502e39449afcfb79b03c88ffbe"
            },
            "downloads": -1,
            "filename": "spacytextblob-5.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ec06ceb766317458b32aa67a751374b2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 246373,
            "upload_time": "2024-10-12T20:19:46",
            "upload_time_iso_8601": "2024-10-12T20:19:46.848664Z",
            "url": "https://files.pythonhosted.org/packages/1c/25/7b1406a8b9465f2febf9b1ec4dfd7928405373685407a36dc1e19b94dc94/spacytextblob-5.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-12 20:19:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "SamEdwardes",
    "github_project": "spacytextblob",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "spacytextblob"
}
        
Elapsed time: 0.37894s