Commit ·
ba8921f
1
Parent(s): a3ee28b
warn for merged span fragments only if it contains real content
Browse files
brat.py
CHANGED
|
@@ -87,10 +87,16 @@ def example_to_document(
|
|
| 87 |
)
|
| 88 |
if merge_non_contiguous_spans:
|
| 89 |
if len(starts) > 1:
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
# just take everything
|
| 95 |
start = min(starts)
|
| 96 |
end = max(ends)
|
|
|
|
| 87 |
)
|
| 88 |
if merge_non_contiguous_spans:
|
| 89 |
if len(starts) > 1:
|
| 90 |
+
# check if the text in between the fragments holds only space
|
| 91 |
+
merged_content_spans = list(zip(ends[:-1],starts[1:]))
|
| 92 |
+
merged_content_spans_filtered = [s.trim() for s in merged_content_spans if s.trim() != ""]
|
| 93 |
+
if len(merged_content_spans_filtered) > 0:
|
| 94 |
+
logger.warning(
|
| 95 |
+
f"document '{doc.id}' contains a non-contiguous span (will be merged into a single span): "
|
| 96 |
+
f"newly covered text parts: {merged_content_spans_filtered}, "
|
| 97 |
+
f"merged span text: '{doc.text[starts[0]:ends[-1]]}', "
|
| 98 |
+
f"annotation: {span_dict}"
|
| 99 |
+
)
|
| 100 |
# just take everything
|
| 101 |
start = min(starts)
|
| 102 |
end = max(ends)
|