Amruthaa commited on
Commit
ba37341
·
1 Parent(s): c05bda0

Adding NER

Browse files
Files changed (1) hide show
  1. app.py +22 -5
app.py CHANGED
@@ -1,16 +1,33 @@
1
  from transformers import pipeline
2
  import gradio as gr
3
 
 
4
  summarizer = pipeline("summarization", model = "facebook/bart-large-cnn")
5
 
6
- def get_summary(input):
7
- output = summarizer(input)
8
  return output[0]["summary_text"]
9
 
 
 
 
 
 
 
 
10
  demo = gr.Blocks()
11
  with demo:
12
- textbox = gr.Textbox(placeholder="Enter text to summarize...", lines=4)
13
- btn = gr.Button("Summarize")
14
- btn.click(get_summary, textbox, textbox)
 
 
 
 
 
 
 
 
 
15
 
16
  demo.launch()
 
1
  from transformers import pipeline
2
  import gradio as gr
3
 
4
+ # text summarizer
5
  summarizer = pipeline("summarization", model = "facebook/bart-large-cnn")
6
 
7
+ def get_summary(text):
8
+ output = summarizer(text)
9
  return output[0]["summary_text"]
10
 
11
+ # named entity recognition
12
+ ner_model = pipleine("ner", model = "dslim/bert-large-NER")
13
+
14
+ def gen_ner(text):
15
+ output = ner_model(text)
16
+ return output
17
+
18
  demo = gr.Blocks()
19
  with demo:
20
+ gr.Markdown("Try out multiple NLP tasks!")
21
+ with gr.Tab("Text Summarizer"):
22
+ sum_input = gr.Textbox(placeholder="Enter text to summarize...", lines=4)
23
+ sum_output = gr.Textbox()
24
+ sum_btn = gr.Button("Summarize")
25
+ sum_btn.click(get_summary, sum_input, sum_output)
26
+ with gr.Tab("Named Entity Recognition"):
27
+ ner_input = gr.Textbox(placeholder = "Enter text...", lines = 4)
28
+ ner_output = gr.Textbox()
29
+ ner_btn = gr.Button("Get named entities")
30
+ ner_btn.click(get_ner, ner_input, ner_output)
31
+
32
 
33
  demo.launch()