Require api keys

This commit is contained in:
Madison May
2015-04-07 19:08:40 -04:00
parent 7cde7a7fdb
commit f7c263dc9c
16 changed files with 182 additions and 253 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
from indicoio.utils import api_handler
import indicoio.config as config
def language(text, cloud=config.CLOUD, batch=False, auth=None, **kwargs):
def language(text, cloud=None, batch=False, api_key=None, **kwargs):
"""
Given input text, returns a probability distribution over 33 possible
languages of what language the text was written in.
@@ -24,4 +24,4 @@ def language(text, cloud=config.CLOUD, batch=False, auth=None, **kwargs):
:rtype: Dictionary of language probability pairs
"""
return api_handler(text, cloud=cloud, api="language", batch=batch, auth=auth, **kwargs)
return api_handler(text, cloud=cloud, api="language", batch=batch, api_key=api_key, **kwargs)
+4 -4
View File
@@ -2,7 +2,7 @@ from indicoio import JSON_HEADERS
from indicoio.utils import api_handler
import indicoio.config as config
def political(text, cloud=config.CLOUD, batch=False, auth=None, **kwargs):
def political(text, cloud=None, batch=False, api_key=None, **kwargs):
"""
Given input text, returns a probability distribution over the political alignment of the speaker.
@@ -28,9 +28,9 @@ def political(text, cloud=config.CLOUD, batch=False, auth=None, **kwargs):
:rtype: Dictionary of party probability pairs
"""
return api_handler(text, cloud=cloud, api="political", batch=batch, auth=auth, **kwargs)
return api_handler(text, cloud=cloud, api="political", batch=batch, api_key=api_key, **kwargs)
def posneg(text, cloud=config.CLOUD, batch=False, auth=None, **kwargs):
def posneg(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.
@@ -51,4 +51,4 @@ def posneg(text, cloud=config.CLOUD, batch=False, auth=None, **kwargs):
:rtype: Float
"""
return api_handler(text, cloud=cloud, api="sentiment", batch=batch, auth=auth, **kwargs)
return api_handler(text, cloud=cloud, api="sentiment", batch=batch, api_key=api_key, **kwargs)
+2 -2
View File
@@ -1,7 +1,7 @@
from indicoio.utils import api_handler
import indicoio.config as config
def text_tags(text, cloud=config.CLOUD, batch=False, auth=None, **kwargs):
def text_tags(text, cloud=None, batch=False, api_key=None, **kwargs):
"""
Given input text, returns a probability distribution over 100 document categories
@@ -23,4 +23,4 @@ def text_tags(text, cloud=config.CLOUD, batch=False, auth=None, **kwargs):
:rtype: Dictionary of class probability pairs
"""
return api_handler(text, cloud=cloud, api="texttags", batch=batch, auth=auth, **kwargs)
return api_handler(text, cloud=cloud, api="texttags", batch=batch, api_key=api_key, **kwargs)