|
13 | 13 | Tuple, |
14 | 14 | ) |
15 | 15 |
|
| 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 |
16 | 19 | from transformers import PreTrainedTokenizer |
17 | 20 |
|
18 | 21 | from pytorch_ie.annotations import LabeledSpan, Span |
19 | 22 |
|
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, |
21 | 24 | # remove respective content |
22 | 25 |
|
23 | 26 | TypedSpan = Tuple[int, Tuple[int, int]] |
@@ -229,19 +232,6 @@ def get_token_slice( |
229 | 232 | return start, before_end + 1 |
230 | 233 |
|
231 | 234 |
|
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 | | - |
245 | 235 | def _char_to_token_mapper( |
246 | 236 | char_idx: int, |
247 | 237 | char_to_token_mapping: Dict[int, int], |
|
0 commit comments