jaimin commited on
Commit
12c6e97
1 Parent(s): 0d660ce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import wikipedia
2
  import gradio as gr
3
  from gradio.mix import Parallel
@@ -10,10 +11,7 @@ nltk.download('punkt')
10
 
11
 
12
  def opendomain(text):
13
- question_words = ["what", "why", "when", "where","name", "is", "how", "do", "does",
14
- "which", "are", "could", "would","should", "has", "have", "whom",
15
- "whose", "don't", "a", "an","?",".","the","i","you","he","she","it",
16
- "that","this",",","am",","]
17
  lower_text = text.lower()
18
  lower_text = word_tokenize(lower_text)
19
  new_text = [i for i in lower_text if i not in question_words]
@@ -35,7 +33,6 @@ def opendomain(text):
35
  if len(result[i]) > 500:
36
  summary_point=result[i].split(".")[0]
37
  answer.append(summary_point)
38
-
39
  l = []
40
  for i in range(len(answer)):
41
  l.append("".join(answer[i]))
@@ -44,8 +41,12 @@ def opendomain(text):
44
  gen_output.append(l[i] + ".")
45
 
46
  listToStr = ' '.join([str(elem) for elem in gen_output])
47
- listToStr=listToStr.replace("\n","")
48
  return listToStr
 
 
 
49
  iface = gr.Interface(fn=opendomain, inputs=[gr.inputs.Textbox(lines=5)], outputs="text")
50
  iface.launch()
51
 
 
 
1
+ from gensim.parsing.preprocessing import STOPWORDS
2
  import wikipedia
3
  import gradio as gr
4
  from gradio.mix import Parallel
 
11
 
12
 
13
  def opendomain(text):
14
+ question_words = STOPWORDS.union(set(['likes','play','.',',','like',"don't",'?','use','choose','important','better','?']))
 
 
 
15
  lower_text = text.lower()
16
  lower_text = word_tokenize(lower_text)
17
  new_text = [i for i in lower_text if i not in question_words]
 
33
  if len(result[i]) > 500:
34
  summary_point=result[i].split(".")[0]
35
  answer.append(summary_point)
 
36
  l = []
37
  for i in range(len(answer)):
38
  l.append("".join(answer[i]))
 
41
  gen_output.append(l[i] + ".")
42
 
43
  listToStr = ' '.join([str(elem) for elem in gen_output])
44
+ listToStr = listToStr.replace("\n", "")
45
  return listToStr
46
+ #return final_answer
47
+
48
+
49
  iface = gr.Interface(fn=opendomain, inputs=[gr.inputs.Textbox(lines=5)], outputs="text")
50
  iface.launch()
51
 
52
+