Joshua1808 commited on
Commit
dc1887d
·
1 Parent(s): 6396a19

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -139,10 +139,14 @@ def analizar_frase(frase):
139
  return tabla
140
 
141
  def tweets_localidad(buscar_localidad):
142
- geolocator = Nominatim(user_agent="nombre_del_usuario")
143
- location = geolocator.geocode(buscar_localidad)
144
- radius = "10km"
145
- tweets = api.search_tweets(q="",lang="es",geocode=f"{location.latitude},{location.longitude},{radius}", count = 50, tweet_mode="extended")
 
 
 
 
146
  tweet_list = [i.full_text for i in tweets]
147
  text= pd.DataFrame(tweet_list)
148
  text[0] = text[0].apply(preprocess_tweet)
@@ -152,14 +156,10 @@ def tweets_localidad(buscar_localidad):
152
  if (text.startswith('RT')):
153
  continue
154
  else:
155
- try:
156
- prediction = pipeline_nlp(text)
157
- for predic in prediction:
158
- etiqueta = {'Tweets': text,'Prediccion': predic['label'], 'Probabilidad': predic['score']}
159
- result.append(etiqueta)
160
-
161
- except FileNotFoundError:
162
- st.text("No existe ninguna localidad con ese nombre")
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']))
 
139
  return tabla
140
 
141
  def tweets_localidad(buscar_localidad):
142
+ try:
143
+ geolocator = Nominatim(user_agent="nombre_del_usuario")
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)
 
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']))