pub struct SynonymMap(/* private fields */);Expand description
A canonical-form → synonym-list lookup table.
Built from tab-separated data via SynonymMap::from_tsv. Lookup is
O(log n) via BTreeMap (suitable for sets up to ~5 000 entries; use an
FST-backed map for larger corpora).
Implementations§
Source§impl SynonymMap
impl SynonymMap
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Create an empty SynonymMap (no expansions).
Sourcepub fn from_tsv(data: &str) -> Self
pub fn from_tsv(data: &str) -> Self
Parse a tab-separated synonym table.
Format: canonical\tsyn1\tsyn2\t… — one rule per line.
Lines beginning with # and blank lines are skipped.
Lines with fewer than two tab-separated fields are skipped silently.
Sourcepub fn expand(&self, word: &str) -> Option<&[String]>
pub fn expand(&self, word: &str) -> Option<&[String]>
Look up synonym expansions for word.
Returns None if word has no entry. Returns the full synonym slice
otherwise — the caller should index all returned strings alongside the
canonical form.
Sourcepub fn has_synonyms(&self, word: &str) -> bool
pub fn has_synonyms(&self, word: &str) -> bool
Return true if word has synonym expansions.
Auto Trait Implementations§
impl Freeze for SynonymMap
impl RefUnwindSafe for SynonymMap
impl Send for SynonymMap
impl Sync for SynonymMap
impl Unpin for SynonymMap
impl UnsafeUnpin for SynonymMap
impl UnwindSafe for SynonymMap
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