File size: 306 Bytes
86277c0
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
from pytorch_ie.annotations import LabeledSpan


def labeled_span_to_id(span: LabeledSpan) -> str:
    return f"span-{span.start}-{span.end}-{span.label}"


def labeled_span_from_id(span_id: str) -> LabeledSpan:
    parts = span_id.split("-")
    return LabeledSpan(int(parts[1]), int(parts[2]), parts[3])