use pyo3::prelude::*;
#[pyfunction]
#[pyo3(signature = (text, *, target_script="latin", digit_policy="numeric"))]
pub fn _normalize_confusables(
text: &str,
target_script: &str,
digit_policy: &str,
) -> PyResult<String> {
Ok(crate::confusables::normalize_confusables(
text,
target_script,
digit_policy,
)?)
}
#[pyfunction]
#[pyo3(signature = (text, *, target_script="latin"))]
pub fn _is_confusable(text: &str, target_script: &str) -> PyResult<bool> {
Ok(crate::confusables::is_confusable(text, target_script)?)
}
#[pyfunction]
#[pyo3(signature = (*, target_script="latin"))]
pub fn _unmapped_confusables(target_script: &str) -> PyResult<Vec<String>> {
Ok(crate::confusables::unmapped_confusables(target_script)?
.into_iter()
.map(String::from)
.collect())
}
#[pyfunction]
#[pyo3(signature = (text, *, target_script="latin"))]
pub fn _find_unmapped_confusables(
text: &str,
target_script: &str,
) -> PyResult<Vec<(String, usize)>> {
Ok(
crate::confusables::find_unmapped_confusables(text, target_script)?
.into_iter()
.map(|(ch, offset)| (ch.to_string(), offset))
.collect(),
)
}