Spaces:
Runtime error
Runtime error
Commit
·
4cf8170
1
Parent(s):
0567ede
Update app.py
Browse files
app.py
CHANGED
@@ -107,8 +107,26 @@ def run():
|
|
107 |
|
108 |
if (error == False):
|
109 |
if (termino):
|
110 |
-
new_search = search_words + " -filter:retweets"
|
111 |
-
tweets =tw.Cursor(api.search_tweets,q=new_search,lang="es").items(number_of_tweets)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
elif (usuario):
|
113 |
tweets = api.user_timeline(screen_name = search_words,count=number_of_tweets)
|
114 |
|
|
|
107 |
|
108 |
if (error == False):
|
109 |
if (termino):
|
110 |
+
#new_search = search_words + " -filter:retweets"
|
111 |
+
#tweets =tw.Cursor(api.search_tweets,q=new_search,lang="es").items(number_of_tweets)
|
112 |
+
# Tokenizar la frase
|
113 |
+
tokens = tokenizer.tokenize(frase)
|
114 |
+
# Convertir los tokens a un formato compatible con el modelo
|
115 |
+
input_ids = tokenizer.convert_tokens_to_ids(tokens)
|
116 |
+
attention_masks = [1] * len(input_ids)
|
117 |
+
# Pasar los tokens al modelo
|
118 |
+
outputs = model(torch.tensor([input_ids]), token_type_ids=None, attention_mask=torch.tensor([attention_masks]))
|
119 |
+
|
120 |
+
# Obtener la probabilidad de que la frase sea "sexista"
|
121 |
+
probabilidad_sexista = outputs[0][0][1].item()
|
122 |
+
print(probabilidad_sexista)
|
123 |
+
# Crear un Dataframe
|
124 |
+
text= pd.DataFrame({'palabra': [frase],'probabilidad':[probabilidad_sexista]})
|
125 |
+
#print(text)
|
126 |
+
st.table(text)
|
127 |
+
|
128 |
+
text.plot.bar(y='probabilidad')
|
129 |
+
|
130 |
elif (usuario):
|
131 |
tweets = api.user_timeline(screen_name = search_words,count=number_of_tweets)
|
132 |
|