Skip to main content

A python package for flexible and transparent sentiment analysis.

Project description

Asent: Fast, flexible and transparent sentiment analysis

PyPI version python version Code style: black github actions pytest github actions docs github coverage CodeFactor pip downloads

Asent is a rule-based sentiment analysis library for Python made using SpaCy. It is inspired by Vader, but uses a more modular ruleset, that allows the user to change e.g. the method for finding negations. Furthermore, it includes visualizers to visualize model predictions, making the model easily interpretable.

Installation

Installing Asent is simple using pip:

pip install asent

There is no reason to update from GitHub as the version on pypi should always be the same of on GitHub.

Simple Example

The following shows a simple example of how you can quickly apply sentiment analysis using asent. For more on using asent see the usage guides.

import spacy
import asent

# create spacy pipeline
nlp = spacy.blank('en')
nlp.add_pipe('sentencizer')

# add the rule-based sentiment model
nlp.add_pipe("asent_en_v1")

# try an example
text = "I am not very happy, but I am also not especially sad"
doc = nlp(text)

# print polarity of document, scaled to be between -1, and 1
print(doc._.polarity)
# neg=0.0 neu=0.631 pos=0.369 compound=0.7526

Naturally, a simple score can be quite unsatisfying, thus Asent implements a series of visualizer to interpret the results:

# visualize model prediction
asent.visualize(doc, style="prediction")

If we want to know why the model comes the result it does we can use the analysis style:

# visualize the analysis performed by the model:
asent.visualize(doc[:5], style="analysis")

Where the value in the parenthesis (2.7) indicates the human-rating of the word, while the value outside the parenthesis indicates the value accounting for the negation. Asent also accounts for contrastive conjugations (e.g. but), casing, emoji's and punctuations. For more on how the model works check out the [usage guide].

📖 Documentation

Documentation
🔧 Installation Installation instructions for Asent
📚 Usage Guides Guides and instructions on how to use asent and its features. It also gives short introduction to how the models works.
📰 News and changelog New additions, changes and version history.
🎛 Documentation The detailed reference for Asents's API. Including function documentation

💬 Where to ask questions

Type
🚨 FAQ FAQ
🚨 Bug Reports GitHub Issue Tracker
🎁 Feature Requests & Ideas GitHub Issue Tracker
👩‍💻 Usage Questions GitHub Discussions
🗯 General Discussion GitHub Discussions

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

asent-0.7.4.tar.gz (2.0 MB view details)

Uploaded Source

Built Distribution

asent-0.7.4-py2.py3-none-any.whl (1.0 MB view details)

Uploaded Python 2 Python 3

File details

Details for the file asent-0.7.4.tar.gz.

File metadata

  • Download URL: asent-0.7.4.tar.gz
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/41.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.0.4 tqdm/4.66.1 importlib-metadata/6.8.0 keyring/24.2.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.13

File hashes

Hashes for asent-0.7.4.tar.gz
Algorithm Hash digest
SHA256 80f6e277dd1d619fe2be2babc9b4d6b526484b30846caaaa658ac1a0eaa97fb4
MD5 f889d0f5598de6e24cad8591f388a913
BLAKE2b-256 3ed451b91a529a285638be1245d254c0ab76e85999670c0b3d54a1a527fc774f

See more details on using hashes here.

File details

Details for the file asent-0.7.4-py2.py3-none-any.whl.

File metadata

  • Download URL: asent-0.7.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/41.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.0.4 tqdm/4.66.1 importlib-metadata/6.8.0 keyring/24.2.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.13

File hashes

Hashes for asent-0.7.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 fbf1f7cdb4cce261af4ea800522e43ced605220a0a7f776097e13412a3a513b0
MD5 a09bb257ec6be0bd6b2314e331e0bd9a
BLAKE2b-256 0f6e1e6850e4c35cfc21b0ffcaac4b17a4358daeae0c546eb1c0378a6c458277

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