Skip to content

Commit b9078aa

Browse files
committed
remove is_contained_in and has_overlap, but re-export them from pie-modules; remove empty test file
1 parent 39d0d94 commit b9078aa

File tree

2 files changed

+4
-456
lines changed

2 files changed

+4
-456
lines changed

src/pytorch_ie/utils/span.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@
1313
Tuple,
1414
)
1515

16+
# backwards compatibility imports from pie_modules.utils.span
17+
from pie_modules.utils.span import have_overlap as has_overlap
18+
from pie_modules.utils.span import is_contained_in
1619
from transformers import PreTrainedTokenizer
1720

1821
from pytorch_ie.annotations import LabeledSpan, Span
1922

20-
# TODO: most of this should be superseded by pie_modules.utils.span and pie_modules.utils.sequence_tagging,
23+
# TODO: most of this should be superseded by pie_modules.utils.sequence_tagging,
2124
# remove respective content
2225

2326
TypedSpan = Tuple[int, Tuple[int, int]]
@@ -229,19 +232,6 @@ def get_token_slice(
229232
return start, before_end + 1
230233

231234

232-
def is_contained_in(start_end: Tuple[int, int], other_start_end: Tuple[int, int]) -> bool:
233-
return other_start_end[0] <= start_end[0] and start_end[1] <= other_start_end[1]
234-
235-
236-
def has_overlap(start_end: Tuple[int, int], other_start_end: Tuple[int, int]):
237-
return (
238-
start_end[0] <= other_start_end[0] < start_end[1]
239-
or start_end[0] < other_start_end[1] <= start_end[1]
240-
or other_start_end[0] <= start_end[0] < other_start_end[1]
241-
or other_start_end[0] < start_end[1] <= other_start_end[1]
242-
)
243-
244-
245235
def _char_to_token_mapper(
246236
char_idx: int,
247237
char_to_token_mapping: Dict[int, int],

0 commit comments

Comments
 (0)