tomsoderlund's picture
process_swedish_text v2
ac76be2
raw
history blame
636 Bytes
import gradio as gr
# Models from https://huggingface.co/models
# https://huggingface.co/KBLab/bert-base-swedish-cased-ner
ml_model = 'KBLab/bert-base-swedish-cased-ner'
ner_pipeline = pipeline(model=ml_model, task='ner')
def process_swedish_text(text):
pipeline_results = ner_pipeline(text)
print('NER results:', pipeline_results)
pipeline_results_adjusted = map(lambda entity: entity | { 'score': float(entity['score']) }, pipeline_results)
print(pipeline_results_adjusted)
return pipeline_results_adjusted
gradio_interface = gr.Interface(fn=process_swedish_text, inputs="text", outputs="JSON")
gradio_interface.launch()