From 2c5966d399dd7bb260e97e9bda078058b69b1552 Mon Sep 17 00:00:00 2001 From: Slater-Victoroff Date: Sun, 4 May 2014 22:13:23 -0400 Subject: [PATCH] Basic API working for sentiment --- IndicoIo/images/facial_features.py | 0 IndicoIo/images/fer.py | 0 IndicoIo/text/sentiment.py | 24 ++++++++++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 IndicoIo/images/facial_features.py create mode 100644 IndicoIo/images/fer.py create mode 100644 IndicoIo/text/sentiment.py diff --git a/IndicoIo/images/facial_features.py b/IndicoIo/images/facial_features.py new file mode 100644 index 0000000..e69de29 diff --git a/IndicoIo/images/fer.py b/IndicoIo/images/fer.py new file mode 100644 index 0000000..e69de29 diff --git a/IndicoIo/text/sentiment.py b/IndicoIo/text/sentiment.py new file mode 100644 index 0000000..0fad602 --- /dev/null +++ b/IndicoIo/text/sentiment.py @@ -0,0 +1,24 @@ +import requests +import json + +base_url = lambda c: "http://localhost/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) + 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) + return json.loads(response.content) + +def sentiment(test_text): + data_dict = json.dumps({'text': test_text}) + response = requests.post(base_url("sentiment"), data=data_dict, headers=headers) + return json.loads(response.content) + +print political("Guns don't kill people, people kill people.") +print spam("Get a Free Car!!") +print sentiment("Worst Car Ever.")