artistpath_core/
string_normalization.rs1use 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) .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}