pub struct Normalizer { /* private fields */ }Expand description
WeText Normalizer
Main entry point for text normalization functionality. Supports Text Normalization (TN) and Inverse Text Normalization (ITN) for Chinese, English, and Japanese.
§Example
ⓘ
use wetext_rs::{Normalizer, NormalizerConfig, Language};
let config = NormalizerConfig::new().with_lang(Language::Zh);
let mut normalizer = Normalizer::new("path/to/fsts", config);
let result = normalizer.normalize("2024年").unwrap();
// Result: "二零二四年"Implementations§
Source§impl Normalizer
impl Normalizer
Sourcepub fn new<P: AsRef<Path>>(fst_dir: P, config: NormalizerConfig) -> Self
pub fn new<P: AsRef<Path>>(fst_dir: P, config: NormalizerConfig) -> Self
Create a new Normalizer
§Arguments
fst_dir- Directory containing FST weight filesconfig- Normalizer configuration
Sourcepub fn with_defaults<P: AsRef<Path>>(fst_dir: P) -> Self
pub fn with_defaults<P: AsRef<Path>>(fst_dir: P) -> Self
Create a Normalizer with default configuration
Sourcepub fn normalize(&mut self, text: &str) -> Result<String>
pub fn normalize(&mut self, text: &str) -> Result<String>
Normalize text using the configured settings
Sourcepub fn normalize_with_config(
&mut self,
text: &str,
config: &NormalizerConfig,
) -> Result<String>
pub fn normalize_with_config( &mut self, text: &str, config: &NormalizerConfig, ) -> Result<String>
Normalize text with a specific configuration
Auto Trait Implementations§
impl Freeze for Normalizer
impl RefUnwindSafe for Normalizer
impl Send for Normalizer
impl Sync for Normalizer
impl Unpin for Normalizer
impl UnwindSafe for Normalizer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more