Spaces:
Sleeping
Sleeping
ganeshkamath89
commited on
Commit
•
cb38464
1
Parent(s):
f932059
Trying out a different code to get Wikipedia Summary
Browse files
app.py
CHANGED
@@ -4,34 +4,30 @@ import wikipediaapi
|
|
4 |
import nltk
|
5 |
nltk.download('punkt')
|
6 |
|
7 |
-
def
|
8 |
-
wiki_wiki = wikipediaapi.Wikipedia('
|
9 |
-
|
10 |
-
text = page_py.summary[0:60]
|
11 |
-
summarizer = pipeline("summarization", model = "facebook/bart-large-cnn")
|
12 |
-
return summarizer(text)[0]['summary_text']
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
'''
|
23 |
|
24 |
-
|
25 |
-
extract_article_summary,
|
26 |
-
inputs = gr.Textbox(
|
27 |
-
lines = 2,
|
28 |
-
label = 'URL'
|
29 |
-
),
|
30 |
-
outputs = 'text',
|
31 |
-
title = 'Wikipedia Programming Language Summarizer',
|
32 |
-
theme = 'huggingface',
|
33 |
-
description = desc,
|
34 |
-
examples=sample_url
|
35 |
-
)
|
36 |
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
import nltk
|
5 |
nltk.download('punkt')
|
6 |
|
7 |
+
def get_wiki_summary(search):
|
8 |
+
wiki_wiki = wikipediaapi.Wikipedia('en')
|
9 |
+
page = wiki_wiki.page(search)
|
|
|
|
|
|
|
10 |
|
11 |
+
isExist = page.exists()
|
12 |
+
if not isExist:
|
13 |
+
return isExist, "Not found", "Not found", "Not found", "Not found"
|
14 |
|
15 |
+
url = page.fullurl
|
16 |
+
tittle = page.title
|
17 |
+
summary = page.summary[0:60]
|
18 |
+
text = page.text
|
|
|
19 |
|
20 |
+
return isExist, url, tittle, summary, text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
+
wiki_summary = gr.Interface(
|
23 |
+
get_wiki_summary,
|
24 |
+
gr.Text(label="Search Wikipedia"),
|
25 |
+
[
|
26 |
+
gr.Text(label="Page exists?"),
|
27 |
+
gr.Text(label="URL"),
|
28 |
+
gr.Text(label="Title"),
|
29 |
+
gr.Text(label="Summary"),
|
30 |
+
gr.Text(label="Text")
|
31 |
+
]
|
32 |
+
)
|
33 |
+
wiki_summary.launch()
|