Spaces:
Sleeping
Sleeping
ganeshkamath89
commited on
Commit
•
a58d1af
1
Parent(s):
14ec652
using wikipediaapi to get wikipedia summary
Browse files
app.py
CHANGED
@@ -1,26 +1,20 @@
|
|
1 |
-
from newspaper import Article, Config
|
2 |
from transformers import pipeline
|
3 |
import gradio as gr
|
|
|
4 |
|
5 |
def extract_article_summary(url):
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
text = article.text
|
15 |
-
summarizer = pipeline("summarization", model = "facebook/bart-large-cnn")
|
16 |
-
return summarizer(text)[0]['summary_text']
|
17 |
-
|
18 |
-
sample_url = [['https://en.wikipedia.org/wiki/AMD'],
|
19 |
-
['https://en.wikipedia.org/wiki/Semiconductor_industry'],
|
20 |
-
['https://en.wikipedia.org/wiki/Artificial_intelligence']]
|
21 |
|
22 |
desc = '''
|
23 |
-
Let Hugging Face models summarize articles for you.
|
24 |
Note: Shorter articles generate faster summaries.
|
25 |
This summarizer uses bart-large-cnn model by Facebook
|
26 |
'''
|
@@ -32,7 +26,7 @@ demo = gr.Interface (
|
|
32 |
label = 'URL'
|
33 |
),
|
34 |
outputs = 'text',
|
35 |
-
title = '
|
36 |
theme = 'huggingface',
|
37 |
description = desc,
|
38 |
examples=sample_url
|
|
|
|
|
1 |
from transformers import pipeline
|
2 |
import gradio as gr
|
3 |
+
import wikipediaapi
|
4 |
|
5 |
def extract_article_summary(url):
|
6 |
+
wiki_wiki = wikipediaapi.Wikipedia('MyProjectName (merlin@example.com)', 'en')
|
7 |
+
page_py = wiki_wiki.page("Python_(programming_language)")
|
8 |
+
text = page_py.summary[0:60]
|
9 |
+
summarizer = pipeline("summarization", model = "facebook/bart-large-cnn")
|
10 |
+
return summarizer(text)[0]['summary_text']
|
11 |
|
12 |
+
sample_url = [['AMD'],
|
13 |
+
['Semiconductor_industry'],
|
14 |
+
['Artificial_intelligence']]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
desc = '''
|
17 |
+
Let Hugging Face models summarize Wikipedia articles for you.
|
18 |
Note: Shorter articles generate faster summaries.
|
19 |
This summarizer uses bart-large-cnn model by Facebook
|
20 |
'''
|
|
|
26 |
label = 'URL'
|
27 |
),
|
28 |
outputs = 'text',
|
29 |
+
title = 'Wikipedia Summarizer',
|
30 |
theme = 'huggingface',
|
31 |
description = desc,
|
32 |
examples=sample_url
|