FahadAlam commited on
Commit
be40263
1 Parent(s): bbbdd3a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -4
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 = """What is Lorem Ipsum? Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."""
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
- demo = gr.Interface(fn=wikipediaScrap, inputs=["text", "text"], outputs=["text", "text", "text", "text", gr.Plot()], title="Wikipedia Scrap", examples=examples)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()