pub struct Filter { /* private fields */ }
Expand description
Advanced sensitive word filter with variant detection
Implementations§
Source§impl Filter
impl Filter
Sourcepub fn clear_cache(&self)
pub fn clear_cache(&self)
Clear the cache
Sourcepub fn with_algorithm(algorithm: MatchAlgorithm) -> Self
pub fn with_algorithm(algorithm: MatchAlgorithm) -> Self
Create with specific algorithm
Sourcepub fn with_default_dict() -> Result<Self>
pub fn with_default_dict() -> Result<Self>
Load default dictionary
Sourcepub fn update_noise_pattern(&mut self, pattern: &str)
pub fn update_noise_pattern(&mut self, pattern: &str)
Update noise pattern
Sourcepub fn current_algorithm(&self) -> MatchAlgorithm
pub fn current_algorithm(&self) -> MatchAlgorithm
Get the currently used algorithm
Sourcepub fn load_word_dict<P: AsRef<Path>>(&mut self, path: P) -> Result<()>
pub fn load_word_dict<P: AsRef<Path>>(&mut self, path: P) -> Result<()>
Load dictionary from file
Sourcepub fn replace(&self, text: &str, replacement: char) -> String
pub fn replace(&self, text: &str, replacement: char) -> String
Replace sensitive words with replacement character
Sourcepub fn remove_noise(&self, text: &str) -> String
pub fn remove_noise(&self, text: &str) -> String
Remove only specific noise characters, preserve spaces
Sourcepub fn get_noise_pattern(&self) -> &Regex
pub fn get_noise_pattern(&self) -> &Regex
Get current noise pattern
Source§impl Filter
impl Filter
Sourcepub fn find_all(&self, text: &str) -> Vec<String>
pub fn find_all(&self, text: &str) -> Vec<String>
Optimized method of finding all sensitive words
Sourcepub fn find_all_batch(&self, texts: &[&str]) -> Vec<Vec<String>>
pub fn find_all_batch(&self, texts: &[&str]) -> Vec<Vec<String>>
Bulk search for optimized versions
Sourcepub fn find_all_layered(&self, text: &str) -> Vec<String>
pub fn find_all_layered(&self, text: &str) -> Vec<String>
Hierarchical Matching - Preferential Matching by Sensitive Word Length
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Filter
impl RefUnwindSafe for Filter
impl Send for Filter
impl Sync for Filter
impl Unpin for Filter
impl UnwindSafe for Filter
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