Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -17,10 +17,10 @@ def wikipediaScrap(article_name, wikipedia_language = "en"):
|
|
17 |
page_url = et_page.url
|
18 |
linked_pages = et_page.links
|
19 |
|
20 |
-
text =
|
21 |
|
22 |
# Create and generate a word cloud image:
|
23 |
-
wordcloud = WordCloud().generate(text)
|
24 |
|
25 |
# Display the generated image:
|
26 |
plt.imshow(wordcloud, interpolation='bilinear')
|
@@ -28,7 +28,29 @@ def wikipediaScrap(article_name, wikipedia_language = "en"):
|
|
28 |
|
29 |
return title, content, page_url, "\n". join(linked_pages), plt
|
30 |
|
31 |
-
examples = [["Eiffel Tower", "en"], ["Eiffel tower", 'ur']]
|
32 |
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
demo.launch()
|
|
|
17 |
page_url = et_page.url
|
18 |
linked_pages = et_page.links
|
19 |
|
20 |
+
text = content
|
21 |
|
22 |
# Create and generate a word cloud image:
|
23 |
+
wordcloud = WordCloud(font_path="HelveticaWorld-Regular.ttf").generate(text)
|
24 |
|
25 |
# Display the generated image:
|
26 |
plt.imshow(wordcloud, interpolation='bilinear')
|
|
|
28 |
|
29 |
return title, content, page_url, "\n". join(linked_pages), plt
|
30 |
|
|
|
31 |
|
32 |
+
|
33 |
+
with gr.Blocks() as demo:
|
34 |
+
with gr.Row():
|
35 |
+
inp = gr.Textbox(placeholder="Enter the name of wikipedia article")
|
36 |
+
lan = gr.Textbox(placeholder="Enter the language code")
|
37 |
+
btn = gr.Button("Start Scraping")
|
38 |
+
gr.Markdown("""### Wordcloud""")
|
39 |
+
with gr.Row():
|
40 |
+
with gr.Column():
|
41 |
+
title = gr.Textbox()
|
42 |
+
url = gr.Textbox()
|
43 |
+
with gr.Column():
|
44 |
+
wordcloud = gr.Plot()
|
45 |
+
gr.Markdown("""### Content""")
|
46 |
+
with gr.Row():
|
47 |
+
content = gr.Textbox()
|
48 |
+
gr.Markdown("""### Linked Articles""")
|
49 |
+
with gr.Row():
|
50 |
+
linked = gr.Textbox()
|
51 |
+
with gr.Row():
|
52 |
+
gr.Examples(
|
53 |
+
examples = [["Eiffel Tower", "en"], ["Eiffel tower", 'ur']], fn=wikipediaScrap, inputs=[inp, lan], outputs=[title, content, url, linked, wordcloud], cache_examples=True)
|
54 |
+
btn.click(fn=wikipediaScrap, inputs=[inp, lan], outputs=[title, content, url, linked, wordcloud])
|
55 |
+
|
56 |
demo.launch()
|