An aligned extraction with its byte position in the source text.
byte_start and byte_end are nil when status is :not_found —
the aligner refused to guess rather than ground the extraction at wrong
offsets. Guard offset arithmetic with located?/1.
Summary
Functions
Whether the aligner grounded this span — status is :exact or
:fuzzy, so the byte offsets are present.
Types
@type status() :: :exact | :fuzzy | :not_found
@type t() :: %LangExtract.Alignment.Span{ attributes: map(), byte_end: non_neg_integer() | nil, byte_start: non_neg_integer() | nil, class: String.t() | nil, status: status(), text: String.t() }
Functions
Whether the aligner grounded this span — status is :exact or
:fuzzy, so the byte offsets are present.
The filtering idiom for consumers doing offset arithmetic:
iex> spans = [
...> %LangExtract.Alignment.Span{text: "found", status: :exact, byte_start: 0, byte_end: 5},
...> %LangExtract.Alignment.Span{text: "lost", status: :not_found}
...> ]
iex> Enum.filter(spans, &LangExtract.Alignment.Span.located?/1)
[%LangExtract.Alignment.Span{text: "found", status: :exact, byte_start: 0, byte_end: 5}]