Yong Zhun Hung 6c5c8d7081 Update README.md
2019-12-24 22:32:06 +08:00
2019-11-09 10:44:28 +08:00
2019-11-09 10:11:37 +08:00
2019-03-13 22:28:22 +08:00
2019-12-24 22:32:06 +08:00
2019-11-09 10:11:37 +08:00

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, score='scale')
>>> print(result)

... [0.25,-0.25]
# OR, if you want dual scoring (a score each for positive rating and negative rating)
>>> result = senti.getSentiment(str_arr, score='dual')
>>> print(result)

... [(2, -1), (1, -2)]
# OR, if you want binary scoring (1 for positive sentence, -1 for negative sentence)
>>> result = senti.getSentiment(str_arr, score='binary')
>>> print(result)

... [1, -1]
# OR, if you want trinary scoring (a score each for positive rating, negative rating and neutral rating)
>>> result = senti.getSentiment(str_arr, score='trinary')
>>> print(result)

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

Path Setup

Specify the paths as such:

>>> senti = PySentiStr()
>>> senti.setSentiStrengthPath('C:/Documents/SentiStrength.jar')
>>> senti.setSentiStrengthLanguageFolderPath('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.
S
Description
Better Python 3 wrapper for SentiStrength. SentiStrength is capable of automatic sentiment analysis of up to 16,000 social web texts per second with up to human level accuracy for English.
Readme 5.7 MiB
Languages
Python 94.4%
Shell 5.6%