Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Python 3 Wrapper for SentiStrength, reads a single or multiple input with options for binary class or scale output.

Project description

Python-SentiStrength

Python 3 Wrapper for SentiStrength, reads a single or multiple input with options for binary class or scale output.

Ensure that you have SentiStrength.jar file and SentiStrengthData Language folders, otherwise you can download them from http://sentistrength.wlv.ac.uk/.

Installation

Pip:

pip install sentistrength

Examples

Example use (single string):

>>> from sentistrength import PySentiStr
>>> senti = PySentiStr()
>>> result = senti.getSentiment('What a lovely day')
>>> print(result)

... [0.25]

Example use (list of strings or pandas Series):

>>> from sentistrength import PySentiStr
>>> senti = PySentiStr()
>>> str_arr = ['What a lovely day', 'What a bad day']
>>> result = senti.getSentiment(str_arr)
>>> print(result)

... [0.25,-0.25]
# OR, if want binary scoring (a score each for positive rating and negativing rating) instead of scale
>>> result = senti.getSentiment(str_arr, score='binary')
>>> print(result)

... [(2, -1), (1, -2)]

Path Setup

Specify the paths as such:

>>> senti = PySentiStr()
>>> senti.setSentiStrengthPath = ... # e.g. 'C:\Documents\SentiStrength.jar'
>>> senti.setSentiStrengthLanguageFolderPath = ... # e.g. 'C:\Documents\SentiStrengthData\'

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • Big thanks to Dr. Mike Thelwall for access to SentiStrength.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for sentistrength, version 0.0.6
Filename, size File type Python version Upload date Hashes
Filename, size sentistrength-0.0.6-py3-none-any.whl (3.7 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size sentistrength-0.0.6.tar.gz (2.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page