Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
import base64
|
3 |
import fasttext
|
|
|
4 |
|
5 |
st.set_page_config(
|
6 |
page_title="detoxi.ai",
|
@@ -56,15 +57,17 @@ st.write("""<p style='text-align: center; font-size: 24px;'>Это прилож
|
|
56 |
def highlight_obscene_words(text):
|
57 |
label,probs=model.predict(text.lower())
|
58 |
if label[0]=='__label__positive':
|
59 |
-
st.markdown(
|
60 |
-
|
61 |
-
|
62 |
-
)
|
|
|
63 |
else:
|
64 |
-
st.markdown(
|
65 |
-
|
66 |
-
|
67 |
-
)
|
|
|
68 |
|
69 |
# Боковая панель
|
70 |
with st.sidebar:
|
@@ -84,6 +87,6 @@ user_input = st.text_area('',height=200)
|
|
84 |
if st.button("Проверить текст"):
|
85 |
if user_input.strip():
|
86 |
st.subheader("Результат:")
|
87 |
-
highlight_obscene_words(user_input)
|
88 |
else:
|
89 |
st.warning("Пожалуйста, введите текст для проверки")
|
|
|
1 |
import streamlit as st
|
2 |
import base64
|
3 |
import fasttext
|
4 |
+
from annotated_text import annotated_text
|
5 |
|
6 |
st.set_page_config(
|
7 |
page_title="detoxi.ai",
|
|
|
57 |
def highlight_obscene_words(text):
|
58 |
label,probs=model.predict(text.lower())
|
59 |
if label[0]=='__label__positive':
|
60 |
+
#st.markdown(
|
61 |
+
# "<span style='background:#47916B;'>приемлемо</span>",
|
62 |
+
# unsafe_allow_html=True
|
63 |
+
#)
|
64 |
+
return (text+' ', 'приемлемо','#47916B')
|
65 |
else:
|
66 |
+
#st.markdown(
|
67 |
+
# "<span style='background:#ffcccc;'>токсично</span>",
|
68 |
+
# unsafe_allow_html=True
|
69 |
+
#)
|
70 |
+
return (text+' ', 'токсично','#ffcccc')
|
71 |
|
72 |
# Боковая панель
|
73 |
with st.sidebar:
|
|
|
87 |
if st.button("Проверить текст"):
|
88 |
if user_input.strip():
|
89 |
st.subheader("Результат:")
|
90 |
+
annotated_text(highlight_obscene_words(user_input))
|
91 |
else:
|
92 |
st.warning("Пожалуйста, введите текст для проверки")
|