mirror of
https://github.com/mii443/tokenizers.git
synced 2025-08-23 16:49:27 +00:00
Python - Update PyNormalizer interface
This commit is contained in:
@ -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()?;
|
||||
|
Reference in New Issue
Block a user