jaimin commited on
Commit
4fb030b
1 Parent(s): 05743fe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -25
app.py CHANGED
@@ -31,30 +31,24 @@ def bullete(text,wikipedia_language="en"):
31
  result = list(filter(lambda x: x != '', final_out.split('\n\n')))
32
 
33
  answer = []
34
- for i in range(4):
35
- if len(result[i]) > 500:
36
- summary_point=result[i].split(".")[0:3]
37
- answer.append(summary_point)
38
- l = []
39
- for i in range(len(answer)):
40
- l.append("".join(answer[i]))
41
- gen_output = []
42
- for i in range(len(l)):
43
- gen_output.append(l[i] + ".")
44
-
45
- listToStr = ' '.join([str(elem) for elem in gen_output])
46
- listToStr = listToStr.replace("\n", "")
47
- print(listToStr)
48
- nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)
49
- QA_input = {
50
- 'question': text,
51
- 'context': listToStr
52
- }
53
- print(QA_input)
54
- res = nlp(QA_input)
55
- values = list(res.values())[3]
56
-
57
- return values
58
 
59
 
60
  interface = gr.Interface(fn=bullete,
@@ -62,4 +56,4 @@ interface = gr.Interface(fn=bullete,
62
  outputs="text",
63
  title='Bullet Point')
64
 
65
- interface.launch(inline=False)
31
  result = list(filter(lambda x: x != '', final_out.split('\n\n')))
32
 
33
  answer = []
34
+ try:
35
+ for i in range(len(result[0].split('.'))):
36
+ nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)
37
+ QA_input = {
38
+ 'question': text,
39
+ 'context': result[0].split('.')[i]
40
+ }
41
+ res = nlp(QA_input)
42
+ print(QA_input)
43
+ values = list(res.values())[3]
44
+ answer.append(values)
45
+ except:
46
+ gen_output = []
47
+ for i in range(len(answer)):
48
+ gen_output.append("* " + answer[i] + ".")
49
+ paraphrase = "\n".join(gen_output)
50
+ final_answer = paraphrase.replace(" ", " ")
51
+ return final_answer
 
 
 
 
 
 
52
 
53
 
54
  interface = gr.Interface(fn=bullete,
56
  outputs="text",
57
  title='Bullet Point')
58
 
59
+ interface.launch(inline=False)