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
Ensure that you have SentiStrength.jar file and SentiStrengthData folder in the same folder, otherwise you can specify the path:
>>> 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for sentistrength-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3f4fae3ead177c7985bbb4c9cc7b206588cf028ee9c1f9508c8946c5fe341f7 |
|
MD5 | 00bb842a960fa1722c189339dfc6b5f3 |
|
BLAKE2b-256 | 0624f46b78091e3bfdd372d8ed084708d75a838a0ea16af4e3acccda6ffd7231 |