Add local api support, fix test case

This commit is contained in:
Madison May
2014-09-25 17:05:16 -04:00
parent 6898e1ea07
commit a3d4d85412
8 changed files with 46 additions and 15 deletions
+2 -2
View File
@@ -3,7 +3,7 @@ import json
from indicoio import JSON_HEADERS
def language(text):
def language(api_root, text):
"""
Given input text, returns a probability distribution over 33 possible
languages of what language the text was written in.
@@ -27,7 +27,7 @@ def language(text):
"""
data_dict = json.dumps({'text': text})
response = requests.post("http://api.indico.io/language", data=data_dict, headers=JSON_HEADERS)
response = requests.post(api_root + "language", data=data_dict, headers=JSON_HEADERS)
response_dict = response.json()
if len(response_dict) < 2:
raise ValueError(response_dict.values()[0])