Spaces:
Runtime error
Runtime error
Commit
·
f9ed481
1
Parent(s):
9ffd42a
Update app.py
Browse files
app.py
CHANGED
@@ -80,38 +80,40 @@ with colT2:
|
|
80 |
font-size:16px ; font-family: 'Times New Roman'; color: #3358ff;}
|
81 |
</style> """, unsafe_allow_html=True)
|
82 |
|
83 |
-
def analizar_tweets(search_words, number_of_tweets
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
|
|
|
|
115 |
return tabla
|
116 |
|
117 |
def tweets_localidad(buscar_localidad):
|
|
|
80 |
font-size:16px ; font-family: 'Times New Roman'; color: #3358ff;}
|
81 |
</style> """, unsafe_allow_html=True)
|
82 |
|
83 |
+
def analizar_tweets(search_words, number_of_tweets):
|
84 |
+
if(number_of_tweets > 0):
|
85 |
+
tweets = api.user_timeline(screen_name = search_words,tweet_mode="extended", count= number_of_tweets)
|
86 |
+
result = []
|
87 |
+
for tweet in tweets:
|
88 |
+
if (tweet.full_text.startswith('RT')):
|
89 |
+
continue
|
90 |
+
elif not tweet.full_text.strip():
|
91 |
+
continue
|
92 |
+
else:
|
93 |
+
datos = preprocess(tweet.full_text)
|
94 |
+
prediction = pipeline_nlp(datos)
|
95 |
+
for predic in prediction:
|
96 |
+
etiqueta = {'Tweets': datos,'Prediccion': predic['label'], 'Probabilidad': predic['score']}
|
97 |
+
result.append(etiqueta)
|
98 |
+
df = pd.DataFrame(result)
|
99 |
+
df['Prediccion'] = np.where( df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
|
100 |
+
df = df[df["Prediccion"] == 'Sexista']
|
101 |
+
df = df[df["Probabilidad"] > 0.5]
|
102 |
+
tabla = st.table(df.reset_index(drop=True).head(30).style.applymap(color_survived, subset=['Prediccion']))
|
103 |
+
resultado=df.groupby('Prediccion')['Probabilidad'].sum()
|
104 |
+
colores=["#aae977","#EE3555"]
|
105 |
+
fig, ax = plt.subplots(figsize=(1, 1), subplotpars=None)
|
106 |
+
plt.pie(resultado,labels=resultado.index,autopct='%1.1f%%',colors=colores)
|
107 |
+
ax.set_title("Porcentajes por Categorias", fontsize=1, fontweight="bold")
|
108 |
+
plt.rcParams.update({'font.size':1, 'font.weight':'bold'})
|
109 |
+
ax.legend()
|
110 |
+
# Muestra el gráfico
|
111 |
+
plt.show()
|
112 |
+
st.set_option('deprecation.showPyplotGlobalUse', False)
|
113 |
+
st.pyplot()
|
114 |
+
else:
|
115 |
+
tabla = st.text("Ingrese los valores")
|
116 |
+
|
117 |
return tabla
|
118 |
|
119 |
def tweets_localidad(buscar_localidad):
|