pub struct FstDictionary { /* private fields */ }
Expand description
An immutable dictionary allowing for very fast spellchecking.
For dictionaries with changing contents, such as user and file dictionaries, prefer
MutableDictionary
.
Implementations§
Source§impl FstDictionary
impl FstDictionary
Sourcepub fn curated() -> Arc<Self>
pub fn curated() -> Arc<Self>
Create a dictionary from the curated dictionary included in the Harper binary.
Sourcepub fn new(words: Vec<(CharString, DictWordMetadata)>) -> Self
pub fn new(words: Vec<(CharString, DictWordMetadata)>) -> Self
Construct a new FstDictionary
using a word list as a source.
This can be expensive, so only use this if fast fuzzy searches are worth it.
Trait Implementations§
Source§impl Dictionary for FstDictionary
impl Dictionary for FstDictionary
Source§fn contains_word(&self, word: &[char]) -> bool
fn contains_word(&self, word: &[char]) -> bool
Check if the dictionary contains any capitalization of a given word.
Source§fn contains_word_str(&self, word: &str) -> bool
fn contains_word_str(&self, word: &str) -> bool
Check if the dictionary contains any capitalization of a given word.
Source§fn get_lexeme_metadata(
&self,
word: &[char],
) -> Option<Cow<'_, DictWordMetadata>>
fn get_lexeme_metadata( &self, word: &[char], ) -> Option<Cow<'_, DictWordMetadata>>
Get the associated
DictWordMetadata
for any capitalization of a given word.Source§fn get_lexeme_metadata_str(
&self,
word: &str,
) -> Option<Cow<'_, DictWordMetadata>>
fn get_lexeme_metadata_str( &self, word: &str, ) -> Option<Cow<'_, DictWordMetadata>>
Get the associated
DictWordMetadata
for any capitalization of a given word.
If the word isn’t in the dictionary, the resulting metadata will be
empty.Source§fn fuzzy_match(
&self,
word: &[char],
max_distance: u8,
max_results: usize,
) -> Vec<FuzzyMatchResult<'_>>
fn fuzzy_match( &self, word: &[char], max_distance: u8, max_results: usize, ) -> Vec<FuzzyMatchResult<'_>>
Gets best fuzzy match from dictionary
Source§fn fuzzy_match_str(
&self,
word: &str,
max_distance: u8,
max_results: usize,
) -> Vec<FuzzyMatchResult<'_>>
fn fuzzy_match_str( &self, word: &str, max_distance: u8, max_results: usize, ) -> Vec<FuzzyMatchResult<'_>>
Gets best fuzzy match from dictionary
Source§fn words_iter(&self) -> Box<dyn Iterator<Item = &[char]> + Send + '_>
fn words_iter(&self) -> Box<dyn Iterator<Item = &[char]> + Send + '_>
Iterate over the words in the dictionary.
Source§fn word_count(&self) -> usize
fn word_count(&self) -> usize
The number of words in the dictionary.
Source§fn contains_exact_word(&self, word: &[char]) -> bool
fn contains_exact_word(&self, word: &[char]) -> bool
Check if the dictionary contains the exact capitalization of a given word.
Source§fn contains_exact_word_str(&self, word: &str) -> bool
fn contains_exact_word_str(&self, word: &str) -> bool
Check if the dictionary contains the exact capitalization of a given word.
fn get_correct_capitalization_of(&self, word: &[char]) -> Option<&[char]>
Source§impl From<MutableDictionary> for FstDictionary
impl From<MutableDictionary> for FstDictionary
Source§fn from(dict: MutableDictionary) -> Self
fn from(dict: MutableDictionary) -> Self
Converts to this type from the input type.
Source§impl PartialEq for FstDictionary
impl PartialEq for FstDictionary
Auto Trait Implementations§
impl Freeze for FstDictionary
impl RefUnwindSafe for FstDictionary
impl Send for FstDictionary
impl Sync for FstDictionary
impl Unpin for FstDictionary
impl UnwindSafe for FstDictionary
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