Spaces:
Runtime error
Runtime error
Commit
·
2268fdb
1
Parent(s):
c81d27a
log detected entities
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import re
|
|
| 2 |
import gradio as gr
|
| 3 |
from dataclasses import dataclass
|
| 4 |
from prettytable import PrettyTable
|
|
|
|
| 5 |
|
| 6 |
from pytorch_ie.annotations import LabeledSpan, BinaryRelation
|
| 7 |
from pytorch_ie.auto import AutoPipeline
|
|
@@ -12,6 +13,8 @@ import transformer_re_text_classification2
|
|
| 12 |
|
| 13 |
from typing import List
|
| 14 |
|
|
|
|
|
|
|
| 15 |
|
| 16 |
@dataclass
|
| 17 |
class ExampleDocument(TextDocument):
|
|
@@ -44,6 +47,9 @@ def predict(text):
|
|
| 44 |
score=entity.score)
|
| 45 |
if entity.label in re_pipeline.taskmodule.entity_labels:
|
| 46 |
document.entities.append(entity)
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
re_pipeline(document)
|
| 49 |
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
from dataclasses import dataclass
|
| 4 |
from prettytable import PrettyTable
|
| 5 |
+
import logging
|
| 6 |
|
| 7 |
from pytorch_ie.annotations import LabeledSpan, BinaryRelation
|
| 8 |
from pytorch_ie.auto import AutoPipeline
|
|
|
|
| 13 |
|
| 14 |
from typing import List
|
| 15 |
|
| 16 |
+
logger = logging.getLogger(__name__)
|
| 17 |
+
|
| 18 |
|
| 19 |
@dataclass
|
| 20 |
class ExampleDocument(TextDocument):
|
|
|
|
| 47 |
score=entity.score)
|
| 48 |
if entity.label in re_pipeline.taskmodule.entity_labels:
|
| 49 |
document.entities.append(entity)
|
| 50 |
+
logger.warning(f"detected entity: {entity} (added)")
|
| 51 |
+
else:
|
| 52 |
+
logger.warning(f"detected entity: {entity} (NOT added)")
|
| 53 |
|
| 54 |
re_pipeline(document)
|
| 55 |
|