Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Parse manifesto files to get positive and negative sentiment.
#!/usr/bin/python
import urllib
import requests
party = "name_of_the_party"
lines = []
for line in open("programa-%s.txt" % party , "r"):
l = line.strip()
try:
int(l)
except:
if l.endswith("-"):
lines.append(l[:-1])
elif l:
lines.append(l)
program = (" ".join(lines)).split(".")
json = []
print len(program)
for sentence in program:
response = requests.get("http://www.viralheat.com/api/sentiment/review.json?text=%s&api_key=<API_KEY>" % urllib.quote(sentence))
print response.content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment