Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,32 +5,37 @@ import gradio as gr
|
|
| 5 |
import nltk
|
| 6 |
from nltk.tokenize import word_tokenize
|
| 7 |
import re
|
|
|
|
| 8 |
nltk.download('punkt')
|
| 9 |
|
| 10 |
model_name = "deepset/roberta-base-squad2"
|
| 11 |
model = AutoModelForQuestionAnswering.from_pretrained(model_name)
|
| 12 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
question_words = STOPWORDS.union(
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
final_out = re.sub(r'\=.+\=', '', text1)
|
| 32 |
result = list(filter(lambda x: x != '', final_out.split('\n\n')))
|
| 33 |
-
|
| 34 |
answer = []
|
| 35 |
try:
|
| 36 |
for i in range(len(result[0].split('.'))):
|
|
@@ -51,11 +56,12 @@ def bullete(text,wikipedia_language="en"):
|
|
| 51 |
final_answer = paraphrase.replace(" ", " ")
|
| 52 |
return final_answer
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
| 56 |
interface = gr.Interface(fn=bullete,
|
| 57 |
inputs="text",
|
| 58 |
outputs="text",
|
| 59 |
title='Bullet Point')
|
| 60 |
|
| 61 |
interface.launch(inline=False)
|
|
|
|
|
|
| 5 |
import nltk
|
| 6 |
from nltk.tokenize import word_tokenize
|
| 7 |
import re
|
| 8 |
+
|
| 9 |
nltk.download('punkt')
|
| 10 |
|
| 11 |
model_name = "deepset/roberta-base-squad2"
|
| 12 |
model = AutoModelForQuestionAnswering.from_pretrained(model_name)
|
| 13 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 14 |
|
| 15 |
+
|
| 16 |
+
def bullete(text, wikipedia_language="en"):
|
| 17 |
+
question_words = STOPWORDS.union(
|
| 18 |
+
set(['likes', 'play', '.', ',', 'like', "don't", '?', 'use', 'choose', 'important', 'better', '?']))
|
| 19 |
+
try:
|
| 20 |
+
lower_text = text.lower()
|
| 21 |
+
lower_text = word_tokenize(lower_text)
|
| 22 |
+
new_text = [i for i in lower_text if i not in question_words]
|
| 23 |
+
new_txt = "".join(new_text)
|
| 24 |
+
if wikipedia_language:
|
| 25 |
+
wikipedia.set_lang(wikipedia_language)
|
| 26 |
+
|
| 27 |
+
et_page = wikipedia.page(new_txt.replace(" ", ""))
|
| 28 |
+
title = et_page.title
|
| 29 |
+
content = et_page.content
|
| 30 |
+
page_url = et_page.url
|
| 31 |
+
linked_pages = et_page.links
|
| 32 |
+
|
| 33 |
+
text1 = content
|
| 34 |
+
except:
|
| 35 |
+
return "Please write correct question"
|
| 36 |
final_out = re.sub(r'\=.+\=', '', text1)
|
| 37 |
result = list(filter(lambda x: x != '', final_out.split('\n\n')))
|
| 38 |
+
|
| 39 |
answer = []
|
| 40 |
try:
|
| 41 |
for i in range(len(result[0].split('.'))):
|
|
|
|
| 56 |
final_answer = paraphrase.replace(" ", " ")
|
| 57 |
return final_answer
|
| 58 |
|
| 59 |
+
|
| 60 |
+
|
| 61 |
interface = gr.Interface(fn=bullete,
|
| 62 |
inputs="text",
|
| 63 |
outputs="text",
|
| 64 |
title='Bullet Point')
|
| 65 |
|
| 66 |
interface.launch(inline=False)
|
| 67 |
+
|