rcodina commited on
Commit
97f5429
1 Parent(s): d1c2105

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +34 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ def neteja():
13
+ return [gr.Textbox(value=None), gr.HighlightedText(value=None)]
14
+
15
+ with gr.Blocks(theme=gr.themes.Glass()) as demo:
16
+ gr.Markdown(
17
+ """
18
+ # Reconeixament d'entitats nomenades en català
19
+ Escriu o copia un text i troba les seves entitats
20
+ """)
21
+ with gr.Row():
22
+ with gr.Column():
23
+ inp = gr.Textbox(label="text", placeholder="Escriu aquí...")
24
+ with gr.Row():
25
+ b1 = gr.Button(value="Neteja")
26
+ b2 = gr.Button("Troba entitats", variant="primary")
27
+ out = gr.HighlightedText(label="sortida")
28
+
29
+ examples = gr.Examples(examples=exemples, inputs=inp, label="Exemple:")
30
+
31
+ b1.click(neteja, outputs=[inp, out])
32
+ b2.click(ner, inputs=inp, outputs=out)
33
+
34
+ demo.launch(show_api=False, auth=("admin", "admin"))
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ transformers
3
+ torch