Dominique69 commited on
Commit
8fa8c73
·
verified ·
1 Parent(s): ae57238

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import gradio as gr
3
+
4
+ ner_pipeline = pipeline(model="projecte-aina/roberta-base-ca-v2-cased-ner")
5
+
6
+ exemples = ["El Joan no ha anat mai a Manresa"]
7
+
8
+ def ner(text):
9
+ output = ner_pipeline(text)
10
+ return {"text": text, "entities": output}
11
+
12
+ demo = gr.Interface(
13
+ ner,
14
+ gr.Textbox(label="Text", placeholder="Escriu aquí..."),
15
+ gr.HighlightedText(label="sortida"),
16
+ allow_flagging="never",
17
+ title="Reconeixament d'entitats nomenades en català",
18
+ description="Escriu o copia un text i troba les seves entitats",
19
+ theme=gr.themes.Glass(),
20
+ submit_btn=gr.Button("Troba entitats", variant="primary"),
21
+ clear_btn=gr.Button("Neteja"),
22
+ examples=exemples
23
+ )
24
+
25
+ demo.launch(show_api=False)