Skip to main content

Sentiment Analysis in Python using a Dictionary Approach

Project description

pysentiment

Overview

This is a library for sentiment analysis in dictionary framework. Two dictionaries are provided in the library, namely, Harvard IV-4 and Loughran and McDonald Financial Sentiment Dictionaries, which are sentiment dictionaries for general and financial sentiment analysis.

See also http://www.wjh.harvard.edu/~inquirer/ and https://www3.nd.edu/~mcdonald/Word_Lists.html .

Introduction

Positive and Negative are word counts for the words in positive and negative sets.

Polarity and Subjectivity are calculated in the same way of Lydia system. See also http://www.cs.sunysb.edu/~skiena/lydia/

Getting Started

pip install pysent3
import pysent3

Usage

To use the Harvard IV-4 dictionary, create an instance of the HIV4 class

import pysent3 as ps
hiv4 = ps.HIV4()
tokens = hiv4.tokenize(text)  # text can be tokenized by other ways
                                  # however, dict in HIV4 is preprocessed
                                  # by the default tokenizer in the library
score = hiv4.get_score(tokens)

HIV4 is a subclass for pysentiment3.base.BaseDict. BaseDict can be inherited by implmenting init_dict to initialize _posset and _negset for the dictionary to calculate 'positive' or 'negative' scores for terms.

Similarly, to use the Loughran and McDonald dictionary:

import pysent3 as ps
lm = ps.LM()
tokens = lm.tokenize(text)
score = lm.get_score(tokens)

Largely based on pysentiment2 created by Nick DeRobertis and based on pysentiment by Zhichao Han. GNU GPL License.

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

pysent3-0.1.2.tar.gz (1.8 MB view details)

Uploaded Source

Built Distribution

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

pysent3-0.1.2-py3-none-any.whl (1.9 MB view details)

Uploaded Python 3

File details

Details for the file pysent3-0.1.2.tar.gz.

File metadata

  • Download URL: pysent3-0.1.2.tar.gz
  • Upload date:
  • Size: 1.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for pysent3-0.1.2.tar.gz
Algorithm Hash digest
SHA256 251343407c335e288c42923c7bae1e658d2f017efe3fb405c227441983941beb
MD5 622452fb261a9bbf2b4b2497a4c383ad
BLAKE2b-256 b30f2d3e1414e9649cf2b25e5fc91f649408db29d19cfaf8c23a7aaf9671520b

See more details on using hashes here.

File details

Details for the file pysent3-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pysent3-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 1.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for pysent3-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 05a1b5f5921295e1fe52efd424fa57f73acd198b8503f7e7a165faa92e0fcd6f
MD5 2dde16740d86f7218c223d0fa441908f
BLAKE2b-256 d95743c104b4d32a667a61fce6d4381b584db7ed29883466578709a233f41694

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