Python - Update PyNormalizer interface

This commit is contained in:
Anthony MOI
2020-09-18 16:42:52 -04:00
committed by Anthony MOI
parent bd8f25ee2c
commit b6e7a6e2f7
4 changed files with 29 additions and 3 deletions

View File

@ -5,7 +5,7 @@ use pyo3::prelude::*;
use pyo3::types::*;
use crate::error::ToPyResult;
use crate::utils::PyNormalizedStringRefMut;
use crate::utils::{PyNormalizedString, PyNormalizedStringRefMut};
use serde::ser::SerializeStruct;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use tk::normalizers::{
@ -105,6 +105,10 @@ impl PyNormalizer {
}
}
fn normalize(&self, normalized: &mut PyNormalizedString) -> PyResult<()> {
ToPyResult(self.normalizer.normalize(&mut normalized.normalized)).into()
}
fn normalize_str(&self, sequence: &str) -> PyResult<String> {
let mut normalized = NormalizedString::from(sequence);
ToPyResult(self.normalizer.normalize(&mut normalized)).into_py()?;