Mike
fix some bugs
1da09fe
raw
history blame
1 kB
import gradio as gr
from transformers import pipeline
token_skill_classifier = pipeline(model="jjzha/jobbert_skill_extraction")
token_knowledge_classifier = pipeline(model="jjzha/jobbert_knowledge_extraction")
examples = [
"Knowing Python is a plus.",
]
def ner(text):
output_skills = token_skill_classifier(text)
for result in output_skills:
if result.get("entity"):
tag = result["entity"]
result["entity"] = tag + "-skill"
output_knowledge = token_knowledge_classifier(text)
for result in output_knowledge:
if result.get("entity"):
tag = result["entity"]
result["entity"] = tag + "-knowledge"
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()