Skip to main content

Sentic Package for NLP

Project description

# Sentic

Python Interface for Semantic and Sentiment Analysis using Senticnet4 (

## Install

Using pip:

$ pip install sentic

Using the repository code:

$ python install

## How to use

from sentic import SenticPhrase
text = "Shirley is such a cute girl."
sp = SenticPhrase(text)
>>> {'sentics': {'aptitude': 0.062, 'attention': 0.3695, 'pleasantness': 0.47050000000000003, 'sensitivity': 0.0115}, 'semantics': {'furry', 'labor', 'nocturnal', 'career', 'animal_furry', 'hairy', 'police_work', 'task', 'domestic_pet', 'employment'}, 'moodtags': {'#joy': 2, '#interest': 1, '#admiration': 1}, 'sentiment': 'weak positive', 'polarity': 0.29700000000000004}

>>> sp.get_sentics()
{'aptitude': 0.062, 'attention': 0.3695, 'pleasantness': 0.47050000000000003, 'sensitivity': 0.0115}

>>> sp.get_moodtags()
{'#joy': 2, '#interest': 1, '#admiration': 1}

>>> sp.get_sentiment()
'weak positive'

>>> sp.get_polarity()

>>> sp.get_semantics()
{'furry', 'labor', 'nocturnal', 'career', 'animal_furry', 'hairy', 'police_work', 'task', 'domestic_pet', 'employment'}

Additionally, if you want to, you can just use the same SenticPhrase class object to make method calls on other bodies of text. This manner of functionality was introduced because creating new objects for every different body of text could be cumbersome and memory-inefficient.

# Word not in Sentic word set
{'polarity': 0, 'sentics': {}, 'semantics': set(), 'moodtags': {}, 'sentiment': 'neutral'}

>>>"Humans are such an interesting species.")
{'sentics': {'sensitivity': 0.0, 'aptitude': 0.2995, 'attention': -0.08550000000000002, 'pleasantness': 0.725}, 'sentiment': 'strong positive', 'semantics': set(), 'moodtags': {'#interest': 1, '#joy': 1, '#admiration': 1, '#surprise': 1}, 'polarity': 0.6165}

>>> sp.get_polarity("Use same object to get polarity on another text")

Also, you can use other languages:

from sentic import SenticPhrase
text = 'amour'
sp = SenticPhrase(text, "fr")
>>> ['beaucoup_de_fleurs', 'montrer_l’beaucoup_de_fleurs', 'rose', 'donner_des_fleurs']

>>> ['#intérêt', '#admiration']

>>> {'aptitude': 0.071, 'sensitivity': 0.025, 'pleasantness': 0.027, 'attention': 0.093}

(Unfortunately, the French dataset and some others languages do not have positive/negative labels.)

>>> 0

>>> neutral

You can find all supported languages here:

## About Senticnet

This framework was adapted from Yuri Malheiros (@yurimalheiros)

SenticNet is an initiative conceived at the MIT Media Laboratory in 2010 within an industrial Cooperative Awards in Science and Engineering (CASE) research project, funded by the UK Engineering and Physical Sciences Research Council (EPSRC) and born from the collaboration between the University of Stirling, the Media Lab, and Sitekit Labs.

Currently, both the SenticNet knowledge base and the SenticNet framework are being maintained and further developed by the Sentic Team, a multidisciplinary research group based at the School of Computer Engineering of Nanyang Technological University in Singapore, but also by many other sentic enthusiasts around the world.

Please acknowledge the authors by citing SenticNet 4 in any research work or presentation containing results obtained in whole or in part through the use of the API:

*E. Cambria, S. Poria, R. Bajpai, and B. Schuller. SenticNet 4: A semantic resource for sentiment analysis based on conceptual primitives. In: COLING, pp. 2666-2677, Osaka (2016)*

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 sentic, version 0.0.8
Filename, size File type Python version Upload date Hashes
Filename, size sentic-0.0.8.tar.gz (50.5 MB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page