Falcon based API interface for sentiment analysis over twitter data
pip install -r requirements.txt
Open utils.py file and go to line number 38 - 42 and input your api tokens there
# keys and tokens from the Twitter Dev Console
consumer_key='#YOUR CUSTOMER KEY HERE'
consumer_secret='#YOUR CUSTOMER SECRET HERE'
access_token='#YOUR ACCESS TOKEN HERE'
access_token_secret='YOUR ACCESS TOKEN SECRET HERE'
open terminal and start the server using
bash start.sh
import requests
url = "http://127.0.0.1:8089/api/AnalyzeTweets/"
payload = "{\"query\":\"bjp\"}"
headers = {'cache-control': "no-cache"}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
Returns a json object with
{'PTP': positive tweets percentage
'NTP' : negative tweets percentage
'NTWP': neutral tweets percentage
}
import requests
url = "http://35.196.64.132:8089/api/GetSent/"
payload = "{\"tweet\":\"I was happy to see her again\"}"
headers = {'cache-control': "no-cache"}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
Returns a json object with
{'sentiment':sentiment of the sentence i.e Positive/Negative or Neutral
'polarity': sentiment score
'cleaned_text': processed text
}
import requests
url = "http://35.196.64.132:8089/api/SearchTwitter/"
payload = ""
headers = {'cache-control': "no-cache"}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
Returns a json object with
{'PTP': positive tweets percentage
'NTP' : negative tweets percentage
'NTWP': neutral tweets percentage
'ptweets': All positive tweets
'ntweets' : all negative tweets
}