Skip to main content

verso/library/
normalise.rs

1pub fn normalise_text(s: &str) -> String {
2    let lower = s.to_lowercase();
3    let stripped: String = lower
4        .chars()
5        .map(|c| {
6            if c.is_alphanumeric() || c.is_whitespace() {
7                c
8            } else {
9                ' '
10            }
11        })
12        .collect();
13    stripped.split_whitespace().collect::<Vec<_>>().join(" ")
14}
15
16pub fn normalise_author(s: &str) -> String {
17    normalise_text(s)
18}