jaimin commited on
Commit
4d06235
1 Parent(s): 52d7c0a

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +50 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
10
+
11
+ def opendomain(text):
12
+ question_words = ["what", "why", "when", "where","name", "is", "how", "do", "does",
13
+ "which", "are", "could", "would","should", "has", "have", "whom",
14
+ "whose", "don't", "a", "an","?",".","the","i","you","he","she","it",
15
+ "that","this",",","am",","]
16
+ lower_text = text.lower()
17
+ lower_text = word_tokenize(lower_text)
18
+ new_text = [i for i in lower_text if i not in question_words]
19
+ new_txt = "".join(new_text)
20
+
21
+ r = requests.post(
22
+ url="https://jaimin-new-content.hf.space/run/predict",
23
+ json={"data": [new_txt, "en"]},
24
+ )
25
+ response = r.json()
26
+ text1 = response["data"]
27
+ final_out = text1[0]
28
+ final_out=re.sub(r'\=.+\=', '', final_out)
29
+
30
+ result = list(filter(lambda x: x != '', final_out.split('\n\n')))
31
+
32
+ answer = []
33
+ for i in range(6):
34
+ if len(result[i]) > 500:
35
+ summary_point=result[i].split(".")[0]
36
+ answer.append(summary_point)
37
+ l = []
38
+ for i in range(len(answer)):
39
+ l.append("".join(answer[i]))
40
+ gen_output = []
41
+ for i in range(len(l)):
42
+ gen_output.append("* " + l[i] + ".")
43
+ paraphrase = "\n".join(gen_output)
44
+ final_answer = paraphrase.replace(" ", " ")
45
+ return final_answer
46
+
47
+
48
+ iface = gr.Interface(fn=opendomain, inputs=[gr.inputs.Textbox(lines=5)], outputs="text")
49
+ iface.launch()
50
+
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ wikipedia
2
+ requests
3
+ gradio
4
+ nltk