forked from abishekk92/gimme-song
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsentiment.py
45 lines (29 loc) · 965 Bytes
/
sentiment.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import subprocess
import json
from pprint import pprint
<<<<<<< HEAD
from HTMLParser import HTMLParser
def parseHTML(lyrics):
=======
>>>>>>> 4c8988e641dbf4048ae4b6479ad63d2650042ac3
def curlTextProcessing(text):
curl = "curl -d " + "\"text=" + text + "\"" + " http://text-processing.com/api/sentiment/"
child = subprocess.Popen(curl, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
commsout, commserr = child.communicate()
data = json.loads(commsout)
#pprint(data)
#print "NEG: ", data["probability"]["neg"]
return [data["probability"]["pos"], data["probability"]["neg"], data["probability"]["neutral"]]
<<<<<<< HEAD
if __name__ == '__main__':
text = "Hey Jude, don't make it bad."
l = []
l = curlTextProcessing(text)
print l
=======
#if __name__ == '__main__':
# text = "Hey Jude, don't make it bad."
# l = []
# l = curlTextProcessing(text)
# print l
>>>>>>> 4c8988e641dbf4048ae4b6479ad63d2650042ac3