pub struct SynonymRegistry { /* private fields */ }Expand description
Registry of synonym groups. Each group is an ordered list; ties in recency are broken by registration order (first-registered wins).
An inverted index (index) maps each lowercased word to its group so
that synonyms_for is O(1) rather
than O(groups × group_size).
Implementations§
Source§impl SynonymRegistry
impl SynonymRegistry
pub fn new() -> Self
Sourcepub fn register_group(&mut self, words: &[&str])
pub fn register_group(&mut self, words: &[&str])
Register a new synonym group. Order of insertion is preserved and used to break ties when multiple synonyms have equal recency.
Sourcepub fn synonyms_for(&self, word: &str) -> Option<&[String]>
pub fn synonyms_for(&self, word: &str) -> Option<&[String]>
Look up the synonym group a word belongs to.
Matching is case-insensitive. Returns None when the word is not
registered in any group.
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
Trait Implementations§
Source§impl Clone for SynonymRegistry
impl Clone for SynonymRegistry
Source§fn clone(&self) -> SynonymRegistry
fn clone(&self) -> SynonymRegistry
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SynonymRegistry
impl Debug for SynonymRegistry
Source§impl Default for SynonymRegistry
impl Default for SynonymRegistry
Source§fn default() -> SynonymRegistry
fn default() -> SynonymRegistry
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for SynonymRegistry
impl RefUnwindSafe for SynonymRegistry
impl Send for SynonymRegistry
impl Sync for SynonymRegistry
impl Unpin for SynonymRegistry
impl UnsafeUnpin for SynonymRegistry
impl UnwindSafe for SynonymRegistry
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