sam-pointer-bart-base-v0.3 / annotation_utils.py
ArneBinder's picture
Upload 9 files
86277c0 verified
raw
history blame
306 Bytes
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])