Cricles commited on
Commit
c5c1c41
·
1 Parent(s): 005d53c

Update app.py

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