Spaces:
Runtime error
Runtime error
Commit
·
dad8f09
1
Parent(s):
dc1887d
Update app.py
Browse files
app.py
CHANGED
@@ -144,22 +144,23 @@ def tweets_localidad(buscar_localidad):
|
|
144 |
location = geolocator.geocode(buscar_localidad)
|
145 |
radius = "10km"
|
146 |
tweets = api.search_tweets(q="",lang="es",geocode=f"{location.latitude},{location.longitude},{radius}", count = 50, tweet_mode="extended")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
except AttributeError:
|
148 |
st.text("No existe ninguna localidad con ese nombre")
|
149 |
-
|
150 |
-
tweet_list = [i.full_text for i in tweets]
|
151 |
-
text= pd.DataFrame(tweet_list)
|
152 |
-
text[0] = text[0].apply(preprocess_tweet)
|
153 |
-
text_list = text[0].tolist()
|
154 |
-
result = []
|
155 |
-
for text in text_list:
|
156 |
-
if (text.startswith('RT')):
|
157 |
-
continue
|
158 |
-
else:
|
159 |
-
prediction = pipeline_nlp(text)
|
160 |
-
for predic in prediction:
|
161 |
-
etiqueta = {'Tweets': text,'Prediccion': predic['label'], 'Probabilidad': predic['score']}
|
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']))
|
|
|
144 |
location = geolocator.geocode(buscar_localidad)
|
145 |
radius = "10km"
|
146 |
tweets = api.search_tweets(q="",lang="es",geocode=f"{location.latitude},{location.longitude},{radius}", count = 50, tweet_mode="extended")
|
147 |
+
|
148 |
+
tweet_list = [i.full_text for i in tweets]
|
149 |
+
text= pd.DataFrame(tweet_list)
|
150 |
+
text[0] = text[0].apply(preprocess)
|
151 |
+
text_list = text[0].tolist()
|
152 |
+
result = []
|
153 |
+
for text in text_list:
|
154 |
+
if (text.startswith('RT')):
|
155 |
+
continue
|
156 |
+
else:
|
157 |
+
prediction = pipeline_nlp(text)
|
158 |
+
for predic in prediction:
|
159 |
+
etiqueta = {'Tweets': text,'Prediccion': predic['label'], 'Probabilidad': predic['score']}
|
160 |
+
result.append(etiqueta)
|
161 |
except AttributeError:
|
162 |
st.text("No existe ninguna localidad con ese nombre")
|
163 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
df = pd.DataFrame(result)
|
165 |
df['Prediccion'] = np.where( df['Prediccion'] == 'LABEL_1', 'Sexista', 'No Sexista')
|
166 |
#tabla = st.table(df.reset_index(drop=True).head(30).style.applymap(color_survived, subset=['Prediccion']))
|