Merge pull request #105 from IndicoDataSolutions/Chris/twitter-engagement

ADD: Twitter Engagement
This commit is contained in:
Madison May
2015-07-29 14:00:46 -04:00
4 changed files with 43 additions and 2 deletions
+2 -1
View File
@@ -10,6 +10,7 @@ JSON_HEADERS = {
'version-number': VERSION
}
from indicoio.text.twitter_engagement import twitter_engagement
from indicoio.text.sentiment import political, posneg, sentiment_hq
from indicoio.text.sentiment import posneg as sentiment
from indicoio.text.lang import language
@@ -41,7 +42,7 @@ def detect_batch_decorator(f):
kwargs['batch'] = True
return f(*args, **kwargs)
return wrapper
apis = dict((api, globals().get(api)) for api in API_NAMES)
for api in apis:
+2 -1
View File
@@ -52,7 +52,8 @@ TEXT_APIS = [
'language',
'sentiment_hq',
'keywords',
'named_entities'
'named_entities',
'twitter_engagement'
]
IMAGE_APIS = [
+22
View File
@@ -0,0 +1,22 @@
from indicoio.utils.api import api_handler
import indicoio.config as config
def twitter_engagement(text, cloud=None, batch=False, api_key=None, **kwargs):
"""
Given input text, returns an engagment score between 0 and 1
Example usage:
.. code-block:: python
>>> import indicoio
>>> import numpy as np
>>> text = 'Monday: Delightful with mostly sunny skies. Highs in the low 70s.'
>>> engagement = indicoio.twitter_engagement(text)
:param text: The text to be analyzed.
:type text: str or unicode
:rtype: Float of engagement between 0 and 1
"""
url_params = {"batch": batch, "api_key": api_key}
return api_handler(text, cloud=cloud, api="twitterengagement", url_params=url_params, **kwargs)