Skip to main content

Perform sentiment analysis on text

Project description

pysentimentanalyzer

ci-cd codecov Documentation Status

This package performs sentiment analysis on the given texts and summarizes information from the text.

When a survey asks for written comments, it is often tedious to read through every response to extract useful information or just to get a quick summary. By using this package, responses can be quickly summarized to get a general idea of the sentiments of the comments, which can be useful such as when a PR team wants to know the overall sentiment on a company or when instructors want to know the overall sentiment on a course. The goal is to provide a quick summary that is easily interpretable by combining results from a pre-trained Python natural language processing package with the use of visualizations.

Installation

Ensure that your python version is <=3.9. To install the package, run the following.

pip install pysentimentanalyzer

Usage

This package provides the following 4 functions:

  • generate_wordcloud - Create a wordcloud of the most common positive and negative words.
  • aggregate_sentiment_score - Calculates the overall sentiment score of the input texts.
  • convert_to_likert - Converts the sentiment score to a likert scale ranging from 1-5.
  • sentiment_score_plot - Creates a binned histogram showing count of reviews against the sentiment score.

All functions take a Pandas DataFrame and string of the column name containing the texts as arguments.

See below for an example of how to use the package.

import pandas as pd
from pysentimentanalyzer.generate_wordcloud import *
from pysentimentanalyzer.get_aggregated_sentiment_score import *
from pysentimentanalyzer.likert_scale import *
from pysentimentanalyzer.sentiment_score_plot import *

df = pd.read_csv("test_tweets.csv") # assuming the csv exists in the current directory
df = df.head(200)       
aggregate_sentiment_score(df, "text")
>>> -0.143
convert_to_likert(df, "text")
>>> ('neutral', 3)
sentiment_score_plot(df, "text")

histogram

wordcloud_list = generate_wordcloud(df, "text")
wordcloud_list[0]

wordcloud

Similar Packages

While there exists many packages and libraries for sentiment analysis and many projects built on top of those packages, we could not find specific packages that combines the use of sentiment analysis with visualizations. However, we expect there to be many projects done by individuals that likely perform similar functions by making use of existing NLP packages. Our package aims enhance the existing NLP packages by providing a quick and simple way to generate summary visualizations. Some Python packages that perform sentiment analysis include:

Contributing

This package was created by Group 8 of the DSCI 524 course with members Eric Tsai, Ranjit Sundaramurthi, Tanmay Agarwal and Ziyi Chen. Nonetheless, we welcome suggestions and improvements. See below for further details.

Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.

License

pysentimentanalyzer was created by Eric Tsai, Ranjit Sundaramurthi, Tanmay Agarwal and Ziyi Chen. It is licensed under the terms of the MIT license.

Credits

pysentimentanalyzer was created with cookiecutter and the py-pkgs-cookiecutter template.

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

pysentimentanalyzer-1.0.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysentimentanalyzer-1.0.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file pysentimentanalyzer-1.0.0.tar.gz.

File metadata

  • Download URL: pysentimentanalyzer-1.0.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.1

File hashes

Hashes for pysentimentanalyzer-1.0.0.tar.gz
Algorithm Hash digest
SHA256 bb211c3f1103b802996baf3b26b9808d7b01cc96b6d18f93c8767aa13f7589f2
MD5 f1124e1b68983be8d60a5d7ad7bf0479
BLAKE2b-256 f16d7899ca21cd426906c01c1ce5e1f41197ffcc9f196adeb821936363039aa9

See more details on using hashes here.

File details

Details for the file pysentimentanalyzer-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pysentimentanalyzer-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f9bb2cf7ffc7fca2d7840c6e5aef7b232d700fb533f39f0787c90618593f22a8
MD5 46dc7f410452b697daabe956e6087c0f
BLAKE2b-256 b250b6110549085cab916a55c357114a72dc510f29747064d8336f93f8b59570

See more details on using hashes here.

Supported by

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