mirror of
https://github.com/wassname/IndicoIo-python.git
synced 2026-08-12 11:40:34 +08:00
ADD: sentimenthq
This commit is contained in:
@@ -50,3 +50,26 @@ def posneg(text, cloud=None, batch=False, api_key=None, **kwargs):
|
||||
"""
|
||||
|
||||
return api_handler(text, cloud=cloud, api="sentiment", url_params={"batch":batch, "api_key":api_key}, **kwargs)
|
||||
|
||||
def sentiment_hq(text, cloud=None, batch=False, api_key=None, **kwargs):
|
||||
"""
|
||||
Given input text, returns a scalar estimate of the sentiment of that text.
|
||||
Values are roughly in the range 0 to 1 with 0.5 indicating neutral sentiment.
|
||||
For reference, 0 suggests very negative sentiment and 1 suggests very positive sentiment.
|
||||
|
||||
Example usage:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
>>> from indicoio import sentimenthq
|
||||
>>> text = 'Thanks everyone for the birthday wishes!! It was a crazy few days ><'
|
||||
>>> sentiment = sentimenthq(text)
|
||||
>>> sentiment
|
||||
0.6210052967071533
|
||||
|
||||
:param text: The text to be analyzed.
|
||||
:type text: str or unicode
|
||||
:rtype: Float
|
||||
"""
|
||||
|
||||
return api_handler(text, cloud=cloud, api="sentimenthq", url_params={"batch":batch, "api_key":api_key}, **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user