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]) | |