Spaces:
Running
Running
Mike
commited on
Commit
·
bb98016
1
Parent(s):
daf9711
add both skill and knowledge extractor
Browse files
app.py
CHANGED
@@ -1,7 +1,9 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
|
|
|
|
|
5 |
|
6 |
examples = [
|
7 |
"Knowing Python is a plus.",
|
@@ -9,13 +11,26 @@ examples = [
|
|
9 |
|
10 |
|
11 |
def ner(text):
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
return {"text": text, "entities": output}
|
14 |
|
15 |
|
16 |
-
demo = gr.Interface(ner,
|
17 |
-
gr.Textbox(placeholder="Enter sentence here..."),
|
18 |
-
gr.HighlightedText(),
|
19 |
examples=examples)
|
20 |
|
21 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
token_skill_classifier = pipeline(model="jjzha/jobbert_skill_extraction")
|
5 |
+
token_knowledge_classifier = pipeline(model="jjzha/jobbert_knowledge_extraction")
|
6 |
+
|
7 |
|
8 |
examples = [
|
9 |
"Knowing Python is a plus.",
|
|
|
11 |
|
12 |
|
13 |
def ner(text):
|
14 |
+
output_skills = token_skill_classifier(text)
|
15 |
+
for result in output_skills:
|
16 |
+
if result.get("entity"):
|
17 |
+
tag = results["entity"]
|
18 |
+
results["entity"] = tag + "skill"
|
19 |
+
|
20 |
+
output_knowledge = token_skill_classifier(text)
|
21 |
+
for result in output_knowledge:
|
22 |
+
if result.get("entity"):
|
23 |
+
tag = results["entity"]
|
24 |
+
results["entity"] = tag + "knowledge"
|
25 |
+
|
26 |
+
output = output_skills + output_knowledge
|
27 |
+
|
28 |
return {"text": text, "entities": output}
|
29 |
|
30 |
|
31 |
+
demo = gr.Interface(fn=ner,
|
32 |
+
inputs=gr.Textbox(placeholder="Enter sentence here..."),
|
33 |
+
outputs=gr.HighlightedText(),
|
34 |
examples=examples)
|
35 |
|
36 |
demo.launch()
|