Joshua1808 commited on
Commit
4dcdda4
·
1 Parent(s): 73c054e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -97,23 +97,23 @@ with colT2:
97
 
98
 
99
  def analizar_tweets(search_words, number_of_tweets ):
100
- tweets = api.user_timeline(screen_name = search_words, count= number_of_tweets)
101
- for tweet in tweets:
102
- tweet_list = tweet.text
103
-
104
- #tweet_list = [i.text for i in tweets]
105
  text= pd.DataFrame(tweet_list)
106
- #text[0] = text[0].apply(preprocess_tweet)
107
- text= text.apply(preprocess_tweet)
108
- #text1=text[0].values
109
- predictions = pipeline_nlp(text1)
110
- data = [{'Texto': text, 'Prediccion': prediction['label'], 'Probabilidad': prediction['score']} for prediction in predictions]
111
- # crea un DataFrame a partir de la lista de diccionarios
 
 
 
112
  df = pd.DataFrame(data)
113
  df['Prediccion'] = np.where( df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
114
 
115
  tabla = st.table(df.reset_index(drop=True).head(30).style.applymap(color_survived, subset=['Prediccion']))
116
-
117
  return tabla
118
 
119
  def analizar_frase(frase):
 
97
 
98
 
99
  def analizar_tweets(search_words, number_of_tweets ):
100
+ tweets = api.user_timeline(screen_name = search_words,tweet_mode="extended", count= number_of_tweets)
101
+ tweet_list = [i.full_text for i in tweets]
 
 
 
102
  text= pd.DataFrame(tweet_list)
103
+ text[0] = text[0].apply(preprocess_tweet)
104
+ text_list = text[0].tolist()
105
+ result = []
106
+ for text in text_list:
107
+ prediction = pipeline_nlp(text)
108
+ etiqueta= [{'Tweets': text,'Prediccion': predic['label'], 'Probabilidad': predic['score']} for predic in prediction]
109
+ result.append(etiqueta)
110
+
111
+ #df = pd.DataFrame(result)
112
  df = pd.DataFrame(data)
113
  df['Prediccion'] = np.where( df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
114
 
115
  tabla = st.table(df.reset_index(drop=True).head(30).style.applymap(color_survived, subset=['Prediccion']))
116
+
117
  return tabla
118
 
119
  def analizar_frase(frase):