Spaces:
Runtime error
Runtime error
Commit
路
bfaf0da
1
Parent(s):
dfcadc4
Update app.py
Browse files
app.py
CHANGED
@@ -54,7 +54,7 @@ def preprocess(text):
|
|
54 |
text=" ".join(text.split())
|
55 |
return text
|
56 |
|
57 |
-
def
|
58 |
# Eliminar emojis
|
59 |
tweet = re.sub(r'[\U0001F600-\U0001F64F]', '', tweet)
|
60 |
tweet = re.sub(r'[\U0001F300-\U0001F5FF]', '', tweet)
|
@@ -98,14 +98,13 @@ with colT2:
|
|
98 |
font-size:16px ; font-family: 'Times New Roman'; color: #3358ff;}
|
99 |
</style> """, unsafe_allow_html=True)
|
100 |
|
101 |
-
def
|
102 |
tabla = []
|
103 |
-
if(
|
104 |
try:
|
105 |
# Buscar la informaci贸n del perfil de usuario
|
106 |
-
user = api.get_user(screen_name=
|
107 |
-
|
108 |
-
tweets = api.user_timeline(screen_name = search_words,tweet_mode="extended", count= number_of_tweets)
|
109 |
result = []
|
110 |
for tweet in tweets:
|
111 |
if (tweet.full_text.startswith('RT')):
|
@@ -115,7 +114,7 @@ def analizar_tweets(search_words, number_of_tweets):
|
|
115 |
try:
|
116 |
language = detect(text)
|
117 |
if language == 'es':
|
118 |
-
datos=
|
119 |
if datos == "":
|
120 |
continue
|
121 |
else:
|
@@ -140,8 +139,7 @@ def analizar_tweets(search_words, number_of_tweets):
|
|
140 |
tabla.append(muestra)
|
141 |
else:
|
142 |
muestra= st.text("Ingrese los parametros correspondientes")
|
143 |
-
tabla.append(muestra)
|
144 |
-
|
145 |
return tabla
|
146 |
|
147 |
def tweets_localidad(buscar_localidad):
|
@@ -158,7 +156,7 @@ def tweets_localidad(buscar_localidad):
|
|
158 |
elif not tweet.full_text.strip():
|
159 |
continue
|
160 |
else:
|
161 |
-
datos =
|
162 |
prediction = pipeline_nlp(datos)
|
163 |
for predic in prediction:
|
164 |
etiqueta = {'Tweets': datos,'Prediccion': predic['label'], 'Probabilidad': predic['score']}
|
@@ -254,7 +252,7 @@ def run():
|
|
254 |
analizar_frase(search_words)
|
255 |
|
256 |
elif (usuario):
|
257 |
-
|
258 |
elif (localidad):
|
259 |
tweets_localidad(search_words)
|
260 |
|
|
|
54 |
text=" ".join(text.split())
|
55 |
return text
|
56 |
|
57 |
+
def limpieza_datos(tweet):
|
58 |
# Eliminar emojis
|
59 |
tweet = re.sub(r'[\U0001F600-\U0001F64F]', '', tweet)
|
60 |
tweet = re.sub(r'[\U0001F300-\U0001F5FF]', '', tweet)
|
|
|
98 |
font-size:16px ; font-family: 'Times New Roman'; color: #3358ff;}
|
99 |
</style> """, unsafe_allow_html=True)
|
100 |
|
101 |
+
def tweets_usuario(usuario, cant_de_tweets):
|
102 |
tabla = []
|
103 |
+
if(cant_de_tweets > 0 and usuario != "" ):
|
104 |
try:
|
105 |
# Buscar la informaci贸n del perfil de usuario
|
106 |
+
user = api.get_user(screen_name=usuario)
|
107 |
+
tweets = api.user_timeline(screen_name = usuario,tweet_mode="extended", count= cant_de_tweets)
|
|
|
108 |
result = []
|
109 |
for tweet in tweets:
|
110 |
if (tweet.full_text.startswith('RT')):
|
|
|
114 |
try:
|
115 |
language = detect(text)
|
116 |
if language == 'es':
|
117 |
+
datos=limpieza_datos(text)
|
118 |
if datos == "":
|
119 |
continue
|
120 |
else:
|
|
|
139 |
tabla.append(muestra)
|
140 |
else:
|
141 |
muestra= st.text("Ingrese los parametros correspondientes")
|
142 |
+
tabla.append(muestra)
|
|
|
143 |
return tabla
|
144 |
|
145 |
def tweets_localidad(buscar_localidad):
|
|
|
156 |
elif not tweet.full_text.strip():
|
157 |
continue
|
158 |
else:
|
159 |
+
datos = limpieza_datos(tweet.full_text)
|
160 |
prediction = pipeline_nlp(datos)
|
161 |
for predic in prediction:
|
162 |
etiqueta = {'Tweets': datos,'Prediccion': predic['label'], 'Probabilidad': predic['score']}
|
|
|
252 |
analizar_frase(search_words)
|
253 |
|
254 |
elif (usuario):
|
255 |
+
tweets_usuario(search_words,number_of_tweets)
|
256 |
elif (localidad):
|
257 |
tweets_localidad(search_words)
|
258 |
|