Spaces:
Sleeping
Sleeping
Activate model
Browse files
app.py
CHANGED
@@ -1,21 +1,21 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
|
9 |
-
def run_ner_placeholder(text: str, language: str):
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
|
20 |
def run_ner(text: str, language: str):
|
21 |
token_classifier.model.set_default_language(language)
|
@@ -23,7 +23,7 @@ def run_ner(text: str, language: str):
|
|
23 |
return output
|
24 |
|
25 |
def visualize_ner(text: str, language: str):
|
26 |
-
labels =
|
27 |
return {
|
28 |
"entities": labels,
|
29 |
"text": text,
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
token_classifier = pipeline(
|
5 |
+
model="ZurichNLP/swissbert-ner",
|
6 |
+
aggregation_strategy="simple",
|
7 |
+
)
|
8 |
|
9 |
+
# def run_ner_placeholder(text: str, language: str):
|
10 |
+
# assert language in {"de_CH", "fr_CH", "it_CH", "rm_CH"}, f"Language {language} not supported"
|
11 |
+
# # Placeholder
|
12 |
+
# assert text == "Mein Name sei Gantenbein."
|
13 |
+
# return [{'entity_group': 'PER',
|
14 |
+
# 'score': 0.50026333,
|
15 |
+
# 'word': 'Gantenbein',
|
16 |
+
# 'start': 13,
|
17 |
+
# 'end': 24}
|
18 |
+
# ]
|
19 |
|
20 |
def run_ner(text: str, language: str):
|
21 |
token_classifier.model.set_default_language(language)
|
|
|
23 |
return output
|
24 |
|
25 |
def visualize_ner(text: str, language: str):
|
26 |
+
labels = run_ner(text, language)
|
27 |
return {
|
28 |
"entities": labels,
|
29 |
"text": text,
|