Spaces:
Runtime error
Runtime error
Commit
·
d5cee61
1
Parent(s):
ca3f295
added dropdown of language code
Browse files
app.py
CHANGED
@@ -7,7 +7,9 @@ from PIL import Image
|
|
7 |
from wordcloud import WordCloud, STOPWORDS, ImageColorGenerator
|
8 |
import matplotlib.pyplot as plt
|
9 |
|
10 |
-
def wikipediaScrap(article_name, wikipedia_language = "en"):
|
|
|
|
|
11 |
if wikipedia_language:
|
12 |
wikipedia.set_lang(wikipedia_language)
|
13 |
|
@@ -44,10 +46,23 @@ textarea[data-testid="textbox"] { height: 178px !important}
|
|
44 |
}
|
45 |
"""
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
with gr.Blocks(title="Wikipedia Article Scrape | Data Science Dojo", css = css) as demo:
|
48 |
with gr.Row():
|
49 |
inp = gr.Textbox(placeholder="Enter the name of wikipedia article", label="Wikipedia article name")
|
50 |
-
lan = gr.
|
|
|
51 |
btn = gr.Button("Start Scraping", elem_id="dsd_button")
|
52 |
with gr.Row():
|
53 |
with gr.Column():
|
@@ -65,7 +80,7 @@ with gr.Blocks(title="Wikipedia Article Scrape | Data Science Dojo", css = css)
|
|
65 |
linked = gr.Textbox(label="Linked Articles")
|
66 |
with gr.Row():
|
67 |
gr.Examples(
|
68 |
-
examples = [["Eiffel Tower", "en"], ["Eiffel tower", 'ur']], fn=wikipediaScrap, inputs=[inp, lan], outputs=[title, content, url, linked, wordcloud], cache_examples=True)
|
69 |
btn.click(fn=wikipediaScrap, inputs=[inp, lan], outputs=[title, content, url, linked, wordcloud])
|
70 |
|
71 |
demo.launch()
|
|
|
7 |
from wordcloud import WordCloud, STOPWORDS, ImageColorGenerator
|
8 |
import matplotlib.pyplot as plt
|
9 |
|
10 |
+
def wikipediaScrap(article_name, wikipedia_language = "en - English"):
|
11 |
+
wikipedia_language = wikipedia_language.split(" - ")[0]
|
12 |
+
|
13 |
if wikipedia_language:
|
14 |
wikipedia.set_lang(wikipedia_language)
|
15 |
|
|
|
46 |
}
|
47 |
"""
|
48 |
|
49 |
+
ini_dict = wikipedia.languages()
|
50 |
+
|
51 |
+
# split dictionary into keys and values
|
52 |
+
keys = []
|
53 |
+
values = []
|
54 |
+
language=[]
|
55 |
+
|
56 |
+
items = ini_dict.items()
|
57 |
+
for item in items:
|
58 |
+
keys.append(item[0]), values.append(item[1])
|
59 |
+
language.append(item[0]+" - "+item[1])
|
60 |
+
|
61 |
with gr.Blocks(title="Wikipedia Article Scrape | Data Science Dojo", css = css) as demo:
|
62 |
with gr.Row():
|
63 |
inp = gr.Textbox(placeholder="Enter the name of wikipedia article", label="Wikipedia article name")
|
64 |
+
lan = gr.Dropdown(label=" Select Language", choices=language, value=language[105], interactive=True)
|
65 |
+
|
66 |
btn = gr.Button("Start Scraping", elem_id="dsd_button")
|
67 |
with gr.Row():
|
68 |
with gr.Column():
|
|
|
80 |
linked = gr.Textbox(label="Linked Articles")
|
81 |
with gr.Row():
|
82 |
gr.Examples(
|
83 |
+
examples = [["Eiffel Tower", "en - English"], ["Eiffel tower", 'ur - اردو']], fn=wikipediaScrap, inputs=[inp, lan], outputs=[title, content, url, linked, wordcloud], cache_examples=True)
|
84 |
btn.click(fn=wikipediaScrap, inputs=[inp, lan], outputs=[title, content, url, linked, wordcloud])
|
85 |
|
86 |
demo.launch()
|