Spaces:
Running
Running
File size: 1,165 Bytes
317026d 21d9527 bb98016 317026d bb98016 babd965 bb98016 1da09fe bb98016 babd965 bb98016 317026d bb98016 317026d |
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 36 37 38 |
import gradio as gr
from transformers import pipeline
token_skill_classifier = pipeline(model="jjzha/jobbert_skill_extraction", aggregation_strategy="simple")
token_knowledge_classifier = pipeline(model="jjzha/jobbert_knowledge_extraction", aggregation_strategy="simple")
examples = [
"Knowing Python is a plus.",
]
def ner(text):
output_skills = token_skill_classifier(text)
for result in output_skills:
if result.get("entity_group"):
tag = result["entity_group"]
result["entity"] = tag + "-Skill"
del result["entity_group"]
output_knowledge = token_knowledge_classifier(text)
for result in output_knowledge:
if result.get("entity_group"):
tag = result["entity_group"]
result["entity"] = tag + "-Knowledge"
del result["entity_group"]
output = output_skills + output_knowledge
return {"text": text, "entities": output}
demo = gr.Interface(fn=ner,
inputs=gr.Textbox(placeholder="Enter sentence here..."),
outputs=gr.HighlightedText(),
examples=examples)
demo.launch()
|