awacke1 commited on
Commit
9b973b5
·
1 Parent(s): 8066f29

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -7
app.py CHANGED
@@ -10,15 +10,12 @@ auth = tw.OAuthHandler(consumer_key, consumer_secret)
10
  auth.set_access_token(access_token, access_token_secret)
11
  api = tw.API(auth, wait_on_rate_limit=True)
12
  classifier = pipeline('sentiment-analysis')
13
-
14
- st.title('Live Twitter Sentiment Analysis with Tweepy and HuggingFace Transformers')
15
- st.markdown('This app uses tweepy to get tweets from twitter based on the input name/phrase. It then processes the tweets through HuggingFace transformers pipeline function for sentiment analysis. The resulting sentiments and corresponding tweets are then put in a dataframe for display which is what you see as result.')
16
-
17
  def run():
18
-
19
  with st.form(key='Enter name'):
20
  search_words = st.text_input('Enter the name for which you want to know the sentiment')
21
- number_of_tweets = st.number_input('Enter the number of latest tweets for which you want to know the sentiment(Maximum 50 tweets)', 0,50,10)
22
  submit_button = st.form_submit_button(label='Submit')
23
  if submit_button:
24
  tweets =tw.Cursor(api.search_tweets,q=search_words,lang="en").items(number_of_tweets)
@@ -27,6 +24,5 @@ def run():
27
  q=[p[i]['label'] for i in range(len(p))]
28
  df = pd.DataFrame(list(zip(tweet_list, q)),columns =['Latest '+str(number_of_tweets)+' Tweets'+' on '+search_words, 'sentiment'])
29
  st.write(df)
30
-
31
  if __name__=='__main__':
32
  run()
 
10
  auth.set_access_token(access_token, access_token_secret)
11
  api = tw.API(auth, wait_on_rate_limit=True)
12
  classifier = pipeline('sentiment-analysis')
13
+ st.title('Sentiment Analysis')
14
+ st.markdown('Live Real Time Twitter sentiment enter: @TwitterAccount to see last N sentiments on mentions .')
 
 
15
  def run():
 
16
  with st.form(key='Enter name'):
17
  search_words = st.text_input('Enter the name for which you want to know the sentiment')
18
+ number_of_tweets = st.number_input('Enter the number of latest tweets', 0,100,100)
19
  submit_button = st.form_submit_button(label='Submit')
20
  if submit_button:
21
  tweets =tw.Cursor(api.search_tweets,q=search_words,lang="en").items(number_of_tweets)
 
24
  q=[p[i]['label'] for i in range(len(p))]
25
  df = pd.DataFrame(list(zip(tweet_list, q)),columns =['Latest '+str(number_of_tweets)+' Tweets'+' on '+search_words, 'sentiment'])
26
  st.write(df)
 
27
  if __name__=='__main__':
28
  run()