crabz commited on
Commit
d12ceca
Β·
1 Parent(s): 7507ef9

add short article

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -68,16 +68,16 @@ def postprocess(classifications):
68
  def set_entities(sentence, entities):
69
  doc = nlp(sentence)
70
  ents = []
71
- for ee in entities:
72
- ents.append(doc.char_span(ee[1], ee[2], ee[0]))
73
  doc.ents = ents
74
  return doc
75
 
76
 
77
- def apply_ner(sentence: str):
78
- classifications = ner_pipeline(sentence)
79
  entities = postprocess(classifications)
80
- doc = set_entities(sentence, entities)
81
  displacy_html = displacy.render(doc, style="ent", options=options)
82
  return displacy_html
83
 
@@ -99,6 +99,9 @@ intf = gr.Interface(fn=apply_ner, inputs="text", outputs="html", title='Slovak N
99
  description="Named-entity recognition (NER) labels named-entities in unstructured text. This "
100
  "implementation supports three labels: person (OSOBA), organization (ORGANIZÁCIA) and "
101
  "location (LOKALITA). You can try out one of the examples below or type your own "
102
- "sentence. Don't forget to use double quotes (\" \") instead of curved quotes (β€ž β€œ)",
103
- article="")
 
 
 
104
  intf.launch()
 
68
  def set_entities(sentence, entities):
69
  doc = nlp(sentence)
70
  ents = []
71
+ for label, start, end in entities:
72
+ ents.append(doc.char_span(start, end, label))
73
  doc.ents = ents
74
  return doc
75
 
76
 
77
+ def apply_ner(Sentence: str):
78
+ classifications = ner_pipeline(Sentence)
79
  entities = postprocess(classifications)
80
+ doc = set_entities(Sentence, entities)
81
  displacy_html = displacy.render(doc, style="ent", options=options)
82
  return displacy_html
83
 
 
99
  description="Named-entity recognition (NER) labels named-entities in unstructured text. This "
100
  "implementation supports three labels: person (OSOBA), organization (ORGANIZÁCIA) and "
101
  "location (LOKALITA). You can try out one of the examples below or type your own "
102
+ "sentence. Don't forget to use double quotes (\" \") instead of curved quotes (β€ž β€œ).",
103
+ article="This model is a fine-tuned version of [gerulata/slovakbert]"
104
+ "(https://huggingface.co/gerulata/slovakbert) on the Slovak wikiann dataset. It achieves "
105
+ "F1 score of 0.9398 on the evaluation set. The quote requirements comes from pretrained "
106
+ "SlovakBERT and was not introduced by me.")
107
  intf.launch()