jaimin commited on
Commit
5604717
1 Parent(s): f0f7fb1

Upload 2 files

Browse files
Files changed (2) hide show
  1. para_ans_app.py +51 -0
  2. requirements.txt +4 -0
para_ans_app.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import wikipedia
2
+ import gradio as gr
3
+ from gradio.mix import Parallel
4
+ import requests
5
+ import nltk
6
+ from nltk.tokenize import word_tokenize
7
+ from nltk.tokenize import sent_tokenize
8
+ import re
9
+ 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]
20
+ new_txt = "".join(new_text)
21
+
22
+ r = requests.post(
23
+ url="https://jaimin-new-content.hf.space/run/predict",
24
+ json={"data": [new_txt, "en"]},
25
+ )
26
+ response = r.json()
27
+ text1 = response["data"]
28
+ final_out = text1[0]
29
+ final_out=re.sub(r'\=.+\=', '', final_out)
30
+
31
+ result = list(filter(lambda x: x != '', final_out.split('\n\n')))
32
+
33
+ answer = []
34
+ for i in range(6):
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]))
42
+ gen_output = []
43
+ for i in range(len(l)):
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
+
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ wikipedia
2
+ requests
3
+ gradio
4
+ nltk