jvamvas commited on
Commit
89f894c
1 Parent(s): 9bd0dee

Activate model

Browse files
Files changed (1) hide show
  1. app.py +15 -15
app.py CHANGED
@@ -1,21 +1,21 @@
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,7 +23,7 @@ def run_ner(text: str, language: str):
23
  return output
24
 
25
  def visualize_ner(text: str, language: str):
26
- labels = run_ner_placeholder(text, language)
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,