Text span utilities for Rust and Python
- Rust doc: https://docs.rs/textspan
Usage (Python)
Install: pip install pytextspan
get_original_spans
...
Returns the span indices of original_text
from the tokens based on the shortest edit script (SES).
This is useful, for example, when you want to get the spans in the original text of tokens obtained in the normalized text.
>>>
>>> =
>>>
align_spans
...
Converts the spans defined in text
to those defined in original_text
.
It is useful, for example, when you want to get the spans on normalized text but you
want the spans in original, unnormalized text.
>>> =
>>> =
>>>
align_spans_by_mapping
...
Converts the spans by the given mapping
.
>>> =
>>> =
>>>