Spaces:
Sleeping
Sleeping
File size: 1,046 Bytes
1eb87da a58d1af 9304022 1eb87da cb38464 084837c cb38464 eb21b56 ff34101 1eb87da cb38464 d0eb069 cb38464 51fa6dc cb38464 85fa6c7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
from transformers import pipeline
import gradio as gr
import wikipediaapi
import nltk
nltk.download('punkt')
def get_wiki_summary(search):
wiki_wiki = wikipediaapi.Wikipedia('MyProjectName (merlin@example.com)', 'en')
page = wiki_wiki.page(search)
isExist = page.exists()
if not isExist:
return isExist, "Not found", "Not found", "Not found", "Not found"
url = page.fullurl
tittle = page.title
text = page.text
#summary = page.summary[0:300]
summary = page.summary
#summarizer = pipeline("summarization", model = "BeenaSamuel/t5_small_cnn_multi_news_abstractive_summarizer_v2")
#summary = summarizer(text)[0]["summary_text"]
return isExist, url, tittle, summary, text
wiki_summary = gr.Interface(
get_wiki_summary,
gr.Text(label="Search Wikipedia"),
[
gr.Text(label="Page exists?"),
gr.Text(label="URL"),
gr.Text(label="Title"),
gr.Text(label="Summary", lines=4),
gr.Text(label="Text", lines=10)
]
)
wiki_summary.launch(share=True) |