pub struct Span {
pub start: usize,
pub end: usize,
pub element: ParsedElement,
}
Expand description
Shows a region of the cleaned transcript which an SSML element applies to.
Fields§
§start: usize
This is the index of span’s start (inclusive) in terms of unicode scalar values - not bytes or graphemes
end: usize
This is the of span’s end (exclusive) in terms of unicode scalar values - not bytes or graphemes
element: ParsedElement
The element contained within this span
Implementations§
Source§impl Span
impl Span
Sourcepub fn maybe_contains(&self, other: &Self) -> bool
pub fn maybe_contains(&self, other: &Self) -> bool
Returns true if a span is contained within another span. This only takes advantage of the start and end indexes. Other constraints such as the fact the parser returns spans in order they’re seen need to be used in combination to see if this really contains the other span. So if you’re going over the list in order you can rely on this but if you’ve rearranged the tag list it may not hold true.
This does handle tags which can’t contain other tags. So <break/><break/>
will appear
with the same start and end. However break has to be an empty tag. This function will
return false. Whereas <s/><s/>
will return true as a sentence can contain other tags. In
future as a sentence cannot contain a sentence this may return false.