File size: 1,266 Bytes
b74e43d
54b835f
 
 
 
 
 
 
 
 
 
 
ac15c13
54b835f
ac15c13
54b835f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b74e43d
c5d6e9a
54b835f
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import streamlit as st
from detoxify import Detoxify

# Set Streamlit app title
st.title("Clean Chat Control")

# Create a text input box for user input
input_text = st.text_area('Enter a sentence')

# Check if there is input text
if input_text:
    # Add a button to trigger moderation
    if st.button("Rate Toxicity!"):
        # Perform toxicity prediction
        with st.spinner("Crunching numbers..."):
            results = Detoxify('original').predict(input_text)

        # Display the results in columns
        st.header("Moderation Results:")
        st.write("Toxicity: {:.2f}".format(results['toxicity']))
        st.write("Severe Toxicity: {:.2f}".format(results['severe_toxicity']))
        st.write("Obscene: {:.2f}".format(results['obscene']))
        st.write("Threat: {:.2f}".format(results['threat']))
        st.write("Insult: {:.2f}".format(results['insult']))
        st.write("Identity Attack: {:.2f}".format(results['identity_attack']))

# Add a brief description of the app
st.markdown("""
This simple app helps you analyze the content of a sentence for toxicity, threats, and insults. 
Enter a sentence in the text box above and click the "Moderate" button to see the results.
""")


st.markdown("""
---
Created with ❤️ by Joas
""")