File size: 1,080 Bytes
6fa9f28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d8f04f8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from transformers import pipeline
import gradio as gr

ner_pipeline = pipeline(model="projecte-aina/roberta-base-ca-v2-cased-ner")

exemples = ["El Joan no ha anat mai a Manresa"]

def ner(text):
    output = ner_pipeline(text)
    return {"text": text, "entities": output}

def neteja():
    return [gr.Textbox(value=None), gr.HighlightedText(value=None)]

with gr.Blocks(theme=gr.themes.Glass()) as demo:
    gr.Markdown(
    """
    # Reconeixament d'entitats nomenades en català
    Escriu o copia un text i troba les seves entitats
    """)
    with gr.Row():
      with gr.Column():
        inp = gr.Textbox(label="text", placeholder="Escriu aquí...")
        with gr.Row():
          b1 = gr.Button(value="Neteja")
          b2 = gr.Button("Troba entitats", variant="primary")
      out = gr.HighlightedText(label="sortida")

    examples = gr.Examples(examples=exemples, inputs=inp, label="Exemple:")
    logout_button = gr.Button("Logout", link="/logout")

    b1.click(neteja, outputs=[inp, out])
    b2.click(ner, inputs=inp, outputs=out)

demo.launch(show_api=False)