pub fn normalize(text: &str) -> Vec<String>Expand description
Normalize text into comparison tokens.
Rules, applied in order:
- Lowercase (
char::to_lowercase, so it is Unicode-aware, not ASCII-only). - Every character that is neither alphanumeric nor
'becomes a space. This strips.,?!:;"and turns-and/into token boundaries. - Leading and trailing
'are trimmed from each token, so'word'normalizes towordwhiledon'tkeeps its apostrophe. - Split on whitespace; empty tokens are dropped.
Digits stay digits and number words stay words, so 250 and
two hundred and fifty are four errors apart. Use
crate::eval::canonicalize to score speech, where that difference is
not a pronunciation difference.