Struct Filter

Source
pub struct Filter { /* private fields */ }
Expand description

Advanced sensitive word filter with variant detection

Implementations§

Source§

impl Filter

Source

pub fn new() -> Self

Create a new filter with default settings

Source

pub fn clear_cache(&self)

Clear the cache

Source

pub fn with_algorithm(algorithm: MatchAlgorithm) -> Self

Create with specific algorithm

Source

pub fn with_default_dict() -> Result<Self>

Load default dictionary

Source

pub fn update_noise_pattern(&mut self, pattern: &str)

Update noise pattern

Source

pub fn add_word(&mut self, word: &str)

Add a sensitive word

Source

pub fn add_words(&mut self, words: &[&str])

Add multiple words

Source

pub fn current_algorithm(&self) -> MatchAlgorithm

Get the currently used algorithm

Source

pub fn del_word(&mut self, word: &str)

Remove a word

Source

pub fn del_words(&mut self, words: &[&str])

Remove multiple words

Source

pub fn load_word_dict<P: AsRef<Path>>(&mut self, path: P) -> Result<()>

Load dictionary from file

Source

pub fn load<R: BufRead>(&mut self, reader: R) -> Result<()>

Load dictionary from reader

Source

pub fn find_in(&self, text: &str) -> (bool, String)

Find first sensitive word

Source

pub fn replace(&self, text: &str, replacement: char) -> String

Replace sensitive words with replacement character

Source

pub fn filter(&self, text: &str) -> String

Filter out sensitive words (remove them completely)

Source

pub fn validate(&self, text: &str) -> (bool, String)

Validate text

Source

pub fn remove_noise(&self, text: &str) -> String

Remove only specific noise characters, preserve spaces

Source

pub fn get_noise_pattern(&self) -> &Regex

Get current noise pattern

Source§

impl Filter

Source

pub fn find_all(&self, text: &str) -> Vec<String>

Optimized method of finding all sensitive words

Source

pub fn find_all_batch(&self, texts: &[&str]) -> Vec<Vec<String>>

Bulk search for optimized versions

Source

pub fn find_all_layered(&self, text: &str) -> Vec<String>

Hierarchical Matching - Preferential Matching by Sensitive Word Length

Source

pub fn find_all_streaming<R: BufRead>(&self, reader: R) -> Result<Vec<String>>

Streaming version - suitable for oversized text

Trait Implementations§

Source§

impl Default for Filter

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.