srini047 commited on
Commit
f652f07
·
1 Parent(s): c76fbf9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -1,14 +1,27 @@
1
  import gradio as gr
2
  from salient import vectr, clf
 
 
3
 
4
  def predict(text):
5
  senti = clf.predict(vectr.transform([text]))
 
 
 
 
 
 
 
6
  if (int(senti)):
7
  text_sent = "Salient"
8
  else:
9
  text_sent = "Not salient"
10
 
11
- return text_sent
 
 
 
 
12
 
13
- demo = gr.Interface(fn=predict, inputs="text", outputs="text")
14
  demo.launch()
 
1
  import gradio as gr
2
  from salient import vectr, clf
3
+ from profanity import pf
4
+ pf.set_censor("@")
5
 
6
  def predict(text):
7
  senti = clf.predict(vectr.transform([text]))
8
+ if(pf.is_profane(text)):
9
+ prof = True
10
+ censored_text = pf.censor(text)
11
+ else:
12
+ prof = False
13
+ censored_text = pf.censor(text)
14
+
15
  if (int(senti)):
16
  text_sent = "Salient"
17
  else:
18
  text_sent = "Not salient"
19
 
20
+ return {
21
+ "salient": text_sent,
22
+ "profanity": prof,
23
+ "censored_text": censored_text
24
+ }
25
 
26
+ demo = gr.Interface(fn=predict, inputs="text", outputs="json")
27
  demo.launch()