brijw commited on
Commit
086961d
1 Parent(s): 5993241

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoTokenizer, AutoModelForTokenClassification,pipeline
3
+
4
+ tokenizer = AutoTokenizer.from_pretrained("dbmdz/electra-large-discriminator-finetuned-conll03-english")
5
+
6
+ model = AutoModelForTokenClassification.from_pretrained("dbmdz/electra-large-discriminator-finetuned-conll03-english")
7
+
8
+
9
+
10
+ ner_pipeline = pipeline("ner",model=model,
11
+ tokenizer=tokenizer)
12
+
13
+ examples = [
14
+ "where did Wandobire's laptop come from, was it africa or uganda?",
15
+ ]
16
+
17
+ examples_2 = [
18
+ "The Intern was oriented on ICT setup and Infrastructure of Soroti University, drafted workplan and started off the Internship. Simon was encouraged to take the Internship seriously as there was a lot to learn.",
19
+ ]
20
+
21
+ examples_3 = [
22
+ "Partially done, expected a better result based on Steven's experienced. More effort needed ...",
23
+ ]
24
+
25
+
26
+
27
+
28
+ def ner_electra(text):
29
+ output = ner_pipeline(text)
30
+ return {"text": text, "entities": output}
31
+
32
+
33
+ gr.Interface(ner_electra,
34
+ gr.Textbox(placeholder="Enter sentence here..."),
35
+ gr.HighlightedText(),
36
+ examples=[[examples],[examples_2],[examples_3],],
37
+ title="Comparative Natural Entity Recognition Model by Brian Joram Wandobire",
38
+ description="takes in a comment as an input and outputs the Entities",
39
+ ).launch()