align_spans

Function align_spans 

Source
pub fn align_spans(
    spans: &[Span],
    text: &str,
    original_text: &str,
) -> Vec<Vec<Span>>
Expand description

Converts the spans defined in text to those defined in original_text.

This is useful, for example, when you want to get the spans in the original text of spans obtained in the normalized text.

§Examples

let spans = [(0, 3), (3, 6)];
let text = "foobarbaz";
let original_text = "FOo.BåR baZ";
assert_eq!(
    textspan::align_spans(&spans, text, original_text),
    [[(0, 3)], [(4, 7)]]
)