Spaces:
Runtime error
Runtime error
fix last entity
Browse files
app.py
CHANGED
|
@@ -96,6 +96,10 @@ def render_sample(subset, pii_type):
|
|
| 96 |
ents.append(Span(doc, start, end, sample['labels'][start][2:]))
|
| 97 |
in_entity = False
|
| 98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
doc.ents = ents
|
| 100 |
output = displacy.render(doc, style="ent", jupyter=False, options=options)
|
| 101 |
return {'document': sample['document']}, output
|
|
@@ -133,5 +137,3 @@ with gr.Blocks() as demo:
|
|
| 133 |
|
| 134 |
# launch app ---
|
| 135 |
demo.launch()
|
| 136 |
-
|
| 137 |
-
# removed competition set ---
|
|
|
|
| 96 |
ents.append(Span(doc, start, end, sample['labels'][start][2:]))
|
| 97 |
in_entity = False
|
| 98 |
|
| 99 |
+
# Add the last entity if we're still in one
|
| 100 |
+
if in_entity:
|
| 101 |
+
ents.append(Span(doc, start, end, sample['labels'][start][2:]))
|
| 102 |
+
|
| 103 |
doc.ents = ents
|
| 104 |
output = displacy.render(doc, style="ent", jupyter=False, options=options)
|
| 105 |
return {'document': sample['document']}, output
|
|
|
|
| 137 |
|
| 138 |
# launch app ---
|
| 139 |
demo.launch()
|
|
|
|
|
|