Spaces:
Runtime error
Runtime error
Commit
·
8c9c4f2
1
Parent(s):
a729b39
Update app.py
Browse files
app.py
CHANGED
@@ -102,7 +102,7 @@ def analizar_tweets(search_words, number_of_tweets ):
|
|
102 |
tweets = api.user_timeline(screen_name = search_words,tweet_mode="extended", count= number_of_tweets)
|
103 |
tweet_list = [i.full_text for i in tweets]
|
104 |
text= pd.DataFrame(tweet_list)
|
105 |
-
text[0] = text[0].apply(
|
106 |
text_list = text[0].tolist()
|
107 |
result = []
|
108 |
for text in text_list:
|
@@ -121,14 +121,10 @@ def analizar_tweets(search_words, number_of_tweets ):
|
|
121 |
return tabla
|
122 |
|
123 |
def analizar_frase(frase):
|
124 |
-
|
125 |
-
#palabra = frase.split()
|
126 |
-
#palabra = frase
|
127 |
-
predictions = pipeline_nlp(frase)
|
128 |
|
|
|
129 |
# convierte las predicciones en una lista de diccionarios
|
130 |
data = [{'Texto': frase, 'Prediccion': prediction['label'], 'Probabilidad': prediction['score']} for prediction in predictions]
|
131 |
-
|
132 |
# crea un DataFrame a partir de la lista de diccionarios
|
133 |
df = pd.DataFrame(data)
|
134 |
df['Prediccion'] = np.where( df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
|
@@ -139,7 +135,6 @@ def analizar_frase(frase):
|
|
139 |
return tabla
|
140 |
|
141 |
def tweets_localidad(buscar_localidad):
|
142 |
-
|
143 |
tabla = pd.DataFrame()
|
144 |
try:
|
145 |
geolocator = Nominatim(user_agent="nombre_del_usuario")
|
@@ -162,8 +157,6 @@ def tweets_localidad(buscar_localidad):
|
|
162 |
result.append(etiqueta)
|
163 |
df = pd.DataFrame(result)
|
164 |
df['Prediccion'] = np.where( df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
|
165 |
-
#tabla = st.table(df.reset_index(drop=True).head(30).style.applymap(color_survived, subset=['Prediccion']))
|
166 |
-
#df['Tweets'] = df['Tweets'].str.replace('RT|@', '')
|
167 |
df=df[df["Prediccion"] == 'Sexista']
|
168 |
tabla = st.table(df.reset_index(drop=True).head(50).style.applymap(color_survived, subset=['Prediccion']))
|
169 |
|
|
|
102 |
tweets = api.user_timeline(screen_name = search_words,tweet_mode="extended", count= number_of_tweets)
|
103 |
tweet_list = [i.full_text for i in tweets]
|
104 |
text= pd.DataFrame(tweet_list)
|
105 |
+
text[0] = text[0].apply(preprocess)
|
106 |
text_list = text[0].tolist()
|
107 |
result = []
|
108 |
for text in text_list:
|
|
|
121 |
return tabla
|
122 |
|
123 |
def analizar_frase(frase):
|
|
|
|
|
|
|
|
|
124 |
|
125 |
+
predictions = pipeline_nlp(frase)
|
126 |
# convierte las predicciones en una lista de diccionarios
|
127 |
data = [{'Texto': frase, 'Prediccion': prediction['label'], 'Probabilidad': prediction['score']} for prediction in predictions]
|
|
|
128 |
# crea un DataFrame a partir de la lista de diccionarios
|
129 |
df = pd.DataFrame(data)
|
130 |
df['Prediccion'] = np.where( df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
|
|
|
135 |
return tabla
|
136 |
|
137 |
def tweets_localidad(buscar_localidad):
|
|
|
138 |
tabla = pd.DataFrame()
|
139 |
try:
|
140 |
geolocator = Nominatim(user_agent="nombre_del_usuario")
|
|
|
157 |
result.append(etiqueta)
|
158 |
df = pd.DataFrame(result)
|
159 |
df['Prediccion'] = np.where( df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
|
|
|
|
|
160 |
df=df[df["Prediccion"] == 'Sexista']
|
161 |
tabla = st.table(df.reset_index(drop=True).head(50).style.applymap(color_survived, subset=['Prediccion']))
|
162 |
|