Batch API support

This commit is contained in:
Madison May
2014-12-18 15:27:16 -05:00
parent cc1d6dc502
commit 9ed17b8f34
9 changed files with 27 additions and 47 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
from indicoio.utils import api_handler
def language(api_root, text):
def language(api_root, text, batch=False):
"""
Given input text, returns a probability distribution over 33 possible
languages of what language the text was written in.
@@ -23,4 +23,4 @@ def language(api_root, text):
:rtype: Dictionary of language probability pairs
"""
return api_handler(text, api_root + "language")
return api_handler(text, api_root + "language", batch=batch)
+4 -4
View File
@@ -1,7 +1,7 @@
from indicoio import JSON_HEADERS
from indicoio.utils import api_handler
def political(api_root, text):
def political(api_root, text, batch=False):
"""
Given input text, returns a probability distribution over the political alignment of the speaker.
@@ -27,9 +27,9 @@ def political(api_root, text):
:rtype: Dictionary of party probability pairs
"""
return api_handler(text, api_root + "political")
return api_handler(text, api_root + "political", batch=batch)
def posneg(api_root, text):
def posneg(api_root, text, batch=False):
"""
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.
@@ -50,4 +50,4 @@ def posneg(api_root, text):
:rtype: Float
"""
return api_handler(text, api_root + "sentiment")
return api_handler(text, api_root + "sentiment", batch=batch)
+2 -2
View File
@@ -1,6 +1,6 @@
from indicoio.utils import api_handler
def text_tags(api_root, text):
def text_tags(api_root, text, batch=False):
"""
Given input text, returns a probability distribution over 100 document categories
@@ -22,4 +22,4 @@ def text_tags(api_root, text):
:rtype: Dictionary of class probability pairs
"""
return api_handler(text, api_root + "texttags")
return api_handler(text, api_root + "texttags", batch=batch)