File size: 618 Bytes
de1732e
 
f652f07
 
de1732e
 
 
f652f07
 
 
 
 
 
 
de1732e
 
 
 
 
f652f07
 
 
 
 
de1732e
f652f07
c76fbf9
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
import gradio as gr
from salient import vectr, clf
from profanity import pf
pf.set_censor("@")

def predict(text):
    senti = clf.predict(vectr.transform([text]))
    if(pf.is_profane(text)):
        prof = True
        censored_text = pf.censor(text)
    else:
        prof = False
        censored_text = pf.censor(text)
    
    if (int(senti)):
        text_sent = "Salient"
    else:
        text_sent = "Not salient"

    return {
        "salient": text_sent,
        "profanity": prof,
        "censored_text": censored_text
    }

demo = gr.Interface(fn=predict, inputs="text", outputs="json")
demo.launch()