Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,8 @@ import itertools
|
|
| 7 |
import collections
|
| 8 |
from collections import Counter
|
| 9 |
import numpy as np
|
|
|
|
|
|
|
| 10 |
#hashtag_phrase ="#datascience"
|
| 11 |
#recent_tweet_count_you_want =100
|
| 12 |
def search_hashtag1(hashtag_phrase,recent_tweet_count_you_want):
|
|
@@ -27,7 +29,8 @@ def search_hashtag1(hashtag_phrase,recent_tweet_count_you_want):
|
|
| 27 |
for tweet in tweepy.Cursor(api.search_tweets, q=hashtag_phrase+' -filter:retweets',lang="en", tweet_mode='extended').items(recent_tweet_count_you_want):
|
| 28 |
timestamp1=tweet.created_at
|
| 29 |
timestamp.append(timestamp1)
|
| 30 |
-
tweet_text1=tweet.full_text.replace('\n',' ').encode('utf-8')
|
|
|
|
| 31 |
tweet_text.append(tweet_text1)
|
| 32 |
user_name1=tweet.user.screen_name.encode('utf-8')
|
| 33 |
user_name.append(user_name1)
|
|
@@ -40,9 +43,15 @@ def search_hashtag1(hashtag_phrase,recent_tweet_count_you_want):
|
|
| 40 |
data5=pd.concat([data4,data3],axis=1)
|
| 41 |
data7=pd.DataFrame(user_id,columns={"user_id"})
|
| 42 |
data6=pd.concat([data5,data7],axis=1)
|
| 43 |
-
data6.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
#data6=data5.head(10)
|
| 45 |
-
return
|
| 46 |
iface = gr.Interface(
|
| 47 |
search_hashtag1,inputs=["text","number"],
|
| 48 |
outputs="dataframe",
|
|
|
|
| 7 |
import collections
|
| 8 |
from collections import Counter
|
| 9 |
import numpy as np
|
| 10 |
+
from transformers import pipeline
|
| 11 |
+
classifier = pipeline('sentiment-analysis')
|
| 12 |
#hashtag_phrase ="#datascience"
|
| 13 |
#recent_tweet_count_you_want =100
|
| 14 |
def search_hashtag1(hashtag_phrase,recent_tweet_count_you_want):
|
|
|
|
| 29 |
for tweet in tweepy.Cursor(api.search_tweets, q=hashtag_phrase+' -filter:retweets',lang="en", tweet_mode='extended').items(recent_tweet_count_you_want):
|
| 30 |
timestamp1=tweet.created_at
|
| 31 |
timestamp.append(timestamp1)
|
| 32 |
+
#tweet_text1=tweet.full_text.replace('\n',' ').encode('utf-8')
|
| 33 |
+
tweet_text1=tweet.full_text
|
| 34 |
tweet_text.append(tweet_text1)
|
| 35 |
user_name1=tweet.user.screen_name.encode('utf-8')
|
| 36 |
user_name.append(user_name1)
|
|
|
|
| 43 |
data5=pd.concat([data4,data3],axis=1)
|
| 44 |
data7=pd.DataFrame(user_id,columns={"user_id"})
|
| 45 |
data6=pd.concat([data5,data7],axis=1)
|
| 46 |
+
tweet_list=data6.tweet_text.to_list()
|
| 47 |
+
p = [i for i in classifier(tweet_list)]
|
| 48 |
+
q=[p[i]['label'] for i in range(len(p))]
|
| 49 |
+
data10=pd.DataFrame(q,columns={"sentiment"})
|
| 50 |
+
data_tweet_final=pd.concat([data6,data10],axis=1)
|
| 51 |
+
data_tweet_final.to_csv("tweet_data2.csv")
|
| 52 |
+
#data6.to_csv("tweet_data1.csv")
|
| 53 |
#data6=data5.head(10)
|
| 54 |
+
return data_tweet_final
|
| 55 |
iface = gr.Interface(
|
| 56 |
search_hashtag1,inputs=["text","number"],
|
| 57 |
outputs="dataframe",
|