pub fn replace_word_numbers(utterance: &str) -> StringExpand description
Scan utterance for word-number spans and replace each with its decimal
representation, returning the modified string.
Spans are found greedily left-to-right. The longest parseable span starting at each position is consumed; overlapping spans are not considered. Words that do not participate in a recognised number span are left in place unchanged (including month names, noise words, etc.).
Ordinal forms ("first", "twenty-third", etc.) are treated identically
to their cardinal equivalents ("one", "twenty-three").
ยงExamples
use partial_date::word_numbers::replace_word_numbers;
assert_eq!(replace_word_numbers("twenty-three"), "23");
assert_eq!(replace_word_numbers("the twenty-third day"), "the 23 day");
assert_eq!(replace_word_numbers("two thousand twenty-four"), "2024");
assert_eq!(replace_word_numbers("31 December two thousand fourteen"), "31 December 2014");