mirror of
https://github.com/wassname/IndicoIo-python.git
synced 2026-07-29 11:15:22 +08:00
fixed up README and did some housecleaning
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
import requests
|
||||
import json
|
||||
from IndicoIo import JSON_HEADERS
|
||||
|
||||
base_url = lambda c: "http://indico.io/api/sentiment/%s/classify" % c
|
||||
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
||||
|
||||
def political(test_text):
|
||||
data_dict = json.dumps({'text': test_text})
|
||||
response = requests.post(base_url("political"), data=data_dict, headers=headers)
|
||||
response = requests.post(base_url("political"), data=data_dict, headers=JSON_HEADERS)
|
||||
return json.loads(response.content)
|
||||
|
||||
def spam(test_text):
|
||||
data_dict = json.dumps({'text': test_text})
|
||||
response = requests.post(base_url("spam"), data=data_dict, headers=headers)
|
||||
response = requests.post(base_url("spam"), data=data_dict, headers=JSON_HEADERS)
|
||||
return json.loads(response.content)
|
||||
|
||||
def posneg(test_text):
|
||||
data_dict = json.dumps({'text': test_text})
|
||||
response = requests.post(base_url("sentiment"), data=data_dict, headers=headers)
|
||||
response = requests.post(base_url("sentiment"), data=data_dict, headers=JSON_HEADERS)
|
||||
return json.loads(response.content)
|
||||
|
||||
Reference in New Issue
Block a user