Cricles commited on
Commit
761d025
·
1 Parent(s): 1fcd304

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
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,9 +56,15 @@ st.write("""<p style='text-align: center; font-size: 24px;'>Это прилож
57
  def highlight_obscene_words(text):
58
  label,probs=model.predict(text)
59
  if label[0]=='__label__positive':
60
- return (text + " ", "приемлемо", "#47916B")
 
 
 
61
  else:
62
- return (text + " ", "токсично", "#ffcccc")
 
 
 
63
 
64
  # Боковая панель
65
  with st.sidebar:
@@ -79,7 +84,6 @@ user_input = st.text_area('',height=200)
79
  if st.button("Проверить текст"):
80
  if user_input.strip():
81
  st.subheader("Результат:")
82
- annotated_content = highlight_obscene_words(user_input)
83
- annotated_text(annotated_content)
84
  else:
85
  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,probs=model.predict(text)
58
  if label[0]=='__label__positive':
59
+ st.markdown(
60
+ "<span style='background:#47916B;'>приемлемо</span>",
61
+ unsafe_allow_html=True
62
+ )
63
  else:
64
+ st.markdown(
65
+ "<span style='background:#ffcccc;'>токсично</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("Пожалуйста, введите текст для проверки")