artistpath_core/
string_normalization.rs

1use unidecode::unidecode;
2
3#[cfg(feature = "python")]
4use pyo3::prelude::*;
5
6#[cfg_attr(feature = "python", pyfunction)]
7pub fn clean_str(input: &str) -> String {
8    unidecode(input) // Convert Unicode to ASCII
9        .trim()
10        .to_lowercase()
11        .split_whitespace()
12        .collect::<Vec<&str>>()
13        .join(" ")
14}
15
16#[cfg(feature = "python")]
17#[pymodule]
18pub fn normalization(m: &Bound<'_, PyModule>) -> PyResult<()> {
19    m.add_function(wrap_pyfunction!(clean_str, m)?)?;
20    Ok(())
21}