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 pysentiment3
import pysentiment3

Usage

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

import pysentiment3 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 pysentiment3 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.1.tar.gz (15.3 kB 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.1-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pysent3-0.1.1.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • 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.1.tar.gz
Algorithm Hash digest
SHA256 19a17c2eade51e712b84405f1151dd721899ad51a1c93c9b9b47a29cc3a846b1
MD5 68a570814e2ed86f85043727fb8060ff
BLAKE2b-256 570066a93afce97045b42d5b92f9d31e37c5c78c58093efe11a4cb064e72d0ff

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysent3-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 446fb1a716b452542def666be123844e4f760da3835b30b5dc13a6a6680f946d
MD5 da120efbc4412f9c7f7b7ccc8d18b85b
BLAKE2b-256 f9ba64d60d96a84cbe1fb6a6ccc3f9a27303b981055c525d21181bcae6fd732d

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