print no labels if subword labels are found or exception is thrown
Browse files
app.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
# -*- coding: utf-8 -*-
|
| 2 |
import os
|
| 3 |
|
| 4 |
-
os.system("pip3 install torch==1.10.1+cpu torchvision==0.11.2+cpu torchaudio==0.10.1+cpu -f "
|
| 5 |
-
|
| 6 |
|
| 7 |
import gradio as gr
|
| 8 |
from transformers import pipeline
|
|
@@ -70,7 +70,10 @@ def set_entities(sentence, entities):
|
|
| 70 |
ents = []
|
| 71 |
for label, start, end in entities:
|
| 72 |
ents.append(doc.char_span(start, end, label))
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
| 74 |
return doc
|
| 75 |
|
| 76 |
|
|
@@ -100,5 +103,6 @@ intf = gr.Interface(fn=apply_ner, inputs="text", outputs="html", title='Slovak N
|
|
| 100 |
"<li><em>Memorial založili v roku 1987 disidenti na čele s laureátom Nobelovej ceny za mier akademikom Andrejom Sacharovom.</em> (year classified as location)</li>"
|
| 101 |
"<li><em>Išla som do Petrozavodska navštíviť vo väzbe Jurija Dmitrijeva, vedúceho karelskej pobočky Memorialu.</em> (<em>Memorialu</em> classified as location instead of organization)</li></ul>"
|
| 102 |
"Year is often missclassified as location, this could be fixed by introducing new time label.<br/>"
|
| 103 |
-
"Location and organization can be difficult to distinguish in some cases, because both are suitable. Is Internation Space Station organization or location?"
|
|
|
|
| 104 |
intf.launch()
|
|
|
|
| 1 |
# -*- coding: utf-8 -*-
|
| 2 |
import os
|
| 3 |
|
| 4 |
+
# os.system("pip3 install torch==1.10.1+cpu torchvision==0.11.2+cpu torchaudio==0.10.1+cpu -f "
|
| 5 |
+
# "https://download.pytorch.org/whl/cpu/torch_stable.html")
|
| 6 |
|
| 7 |
import gradio as gr
|
| 8 |
from transformers import pipeline
|
|
|
|
| 70 |
ents = []
|
| 71 |
for label, start, end in entities:
|
| 72 |
ents.append(doc.char_span(start, end, label))
|
| 73 |
+
try:
|
| 74 |
+
doc.ents = ents
|
| 75 |
+
except TypeError:
|
| 76 |
+
pass
|
| 77 |
return doc
|
| 78 |
|
| 79 |
|
|
|
|
| 103 |
"<li><em>Memorial založili v roku 1987 disidenti na čele s laureátom Nobelovej ceny za mier akademikom Andrejom Sacharovom.</em> (year classified as location)</li>"
|
| 104 |
"<li><em>Išla som do Petrozavodska navštíviť vo väzbe Jurija Dmitrijeva, vedúceho karelskej pobočky Memorialu.</em> (<em>Memorialu</em> classified as location instead of organization)</li></ul>"
|
| 105 |
"Year is often missclassified as location, this could be fixed by introducing new time label.<br/>"
|
| 106 |
+
"Location and organization can be difficult to distinguish in some cases, because both are suitable. Is Internation Space Station organization or location?",
|
| 107 |
+
analytics_enabled=False)
|
| 108 |
intf.launch()
|