Created
January 2, 2014 03:05
-
-
Save tndoan/8214409 to your computer and use it in GitHub Desktop.
It is the example of using Python to request the result from Sentiment 140. This example is based on http://help.sentiment140.com/api
This file contains hidden or 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 urllib2 | |
import json | |
s = '{"data": [{"text": "I love Titanic."},{"text": "I hate Titanic."}]}' # 2 short text that we want to do sentiment analysis | |
response = urllib2.urlopen('http://www.sentiment140.com/api/bulkClassifyJson', s) # request to server | |
page = response.read() # get the response | |
print page # print the result | |
json.loads(page) # parse the result. The result is in JSON format |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For Python 3,