pub struct SemanticGuard { /* private fields */ }Expand description
The Semantic Guard - main entry point for semantic violation detection
Implementations§
Source§impl SemanticGuard
impl SemanticGuard
Sourcepub fn with_ethical_defaults() -> Self
pub fn with_ethical_defaults() -> Self
Create a guard with predefined ethical concepts
Sourcepub fn set_threshold(&mut self, threshold: f64)
pub fn set_threshold(&mut self, threshold: f64)
Set the similarity threshold
Sourcepub fn enable_strict_mode(&mut self)
pub fn enable_strict_mode(&mut self)
Enable strict mode (lowers threshold to 0.3)
Sourcepub fn add_concept(&mut self, concept: ForbiddenConcept)
pub fn add_concept(&mut self, concept: ForbiddenConcept)
Add a forbidden concept
Sourcepub fn add_forbidden(&mut self, phrase: &str)
pub fn add_forbidden(&mut self, phrase: &str)
Add a simple forbidden phrase
Sourcepub fn check(&mut self, text: &str) -> Option<SemanticViolation>
pub fn check(&mut self, text: &str) -> Option<SemanticViolation>
Check text for semantic violations
Sourcepub fn check_batch(&mut self, texts: &[&str]) -> Vec<Option<SemanticViolation>>
pub fn check_batch(&mut self, texts: &[&str]) -> Vec<Option<SemanticViolation>>
Check multiple text segments
Sourcepub fn stats(&self) -> &GuardStats
pub fn stats(&self) -> &GuardStats
Get current statistics
Sourcepub fn clear_cache(&mut self)
pub fn clear_cache(&mut self)
Clear the cache
Sourcepub fn concept_count(&self) -> usize
pub fn concept_count(&self) -> usize
Get the number of forbidden concepts
Trait Implementations§
Source§impl Debug for SemanticGuard
impl Debug for SemanticGuard
Auto Trait Implementations§
impl Freeze for SemanticGuard
impl RefUnwindSafe for SemanticGuard
impl Send for SemanticGuard
impl Sync for SemanticGuard
impl Unpin for SemanticGuard
impl UnwindSafe for SemanticGuard
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