Created
December 15, 2015 02:09
-
-
Save metasyn/82b61e65771659ba291e to your computer and use it in GitHub Desktop.
splunk sentiment analysis with idibon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import httplib | |
import json | |
import splunk.Intersplunk | |
connection = httplib.HTTPConnection("localhost:8080") | |
results,unused1,unused2 = splunk.Intersplunk.getOrganizedResults() | |
for result in results: | |
body = json.dumps({"content": result['text']}) | |
connection.request("GET", "/Idibon/EnglishSocialSentiment", body) | |
response = connection.getresponse() | |
res = response.read() | |
json_res = dict(json.loads(res[1:-1])) | |
result['sentiment'] = json_res['class'] | |
result['confidence'] = json_res['confidence'] | |
splunk.Intersplunk.outputResults(results) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment