pub struct MutableDictionary { /* private fields */ }
Expand description
A basic dictionary that allows words to be added after instantiating. This is useful for user and file dictionaries that may change at runtime.
For immutable use-cases, such as the curated dictionary, prefer super::FstDictionary
,
as it is much faster.
To combine the contents of multiple dictionaries, regardless of type, use
super::MergedDictionary
.
Implementations§
Source§impl MutableDictionary
impl MutableDictionary
pub fn new() -> Self
Sourcepub fn curated() -> Arc<Self>
pub fn curated() -> Arc<Self>
Create a dictionary from the curated dictionary included
in the Harper binary.
Consider using super::FstDictionary::curated()
instead, as it is more performant for spellchecking.
Sourcepub fn extend_words(
&mut self,
words: impl IntoIterator<Item = (impl AsRef<[char]>, WordMetadata)>,
)
pub fn extend_words( &mut self, words: impl IntoIterator<Item = (impl AsRef<[char]>, WordMetadata)>, )
Appends words to the dictionary. It is significantly faster to append many words with one call than many distinct calls to this function.
Sourcepub fn append_word(&mut self, word: impl AsRef<[char]>, metadata: WordMetadata)
pub fn append_word(&mut self, word: impl AsRef<[char]>, metadata: WordMetadata)
Append a single word to the dictionary.
If you are appending many words, consider using Self::extend_words
instead.
Sourcepub fn append_word_str(&mut self, word: &str, metadata: WordMetadata)
pub fn append_word_str(&mut self, word: &str, metadata: WordMetadata)
Append a single string to the dictionary.
If you are appending many words, consider using Self::extend_words
instead.
Trait Implementations§
Source§impl Clone for MutableDictionary
impl Clone for MutableDictionary
Source§fn clone(&self) -> MutableDictionary
fn clone(&self) -> MutableDictionary
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for MutableDictionary
impl Debug for MutableDictionary
Source§impl Default for MutableDictionary
impl Default for MutableDictionary
Source§impl Dictionary for MutableDictionary
impl Dictionary for MutableDictionary
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<'_>>
Suggest a correct spelling for a given misspelled word.
Self::word
is assumed to be quite small (n < 100).
max_distance
relates to an optimization that allows the search
algorithm to prune large portions of the search.
Source§fn get_word_metadata(&self, word: &[char]) -> Option<WordMetadata>
fn get_word_metadata(&self, word: &[char]) -> Option<WordMetadata>
WordMetadata
for any capitalization of a given word.Source§fn contains_word(&self, word: &[char]) -> bool
fn contains_word(&self, word: &[char]) -> bool
Source§fn contains_word_str(&self, word: &str) -> bool
fn contains_word_str(&self, word: &str) -> bool
Source§fn get_word_metadata_str(&self, word: &str) -> Option<WordMetadata>
fn get_word_metadata_str(&self, word: &str) -> Option<WordMetadata>
WordMetadata
for any capitalization of a given word.
If the word isn’t in the dictionary, the resulting metadata will be
empty.fn get_correct_capitalization_of(&self, word: &[char]) -> Option<&[char]>
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<'_>>
Source§fn words_iter(&self) -> Box<dyn Iterator<Item = &[char]> + Send + '_>
fn words_iter(&self) -> Box<dyn Iterator<Item = &[char]> + Send + '_>
Source§fn words_with_len_iter(
&self,
len: usize,
) -> Box<dyn Iterator<Item = &[char]> + Send + '_>
fn words_with_len_iter( &self, len: usize, ) -> Box<dyn Iterator<Item = &[char]> + Send + '_>
Source§fn word_count(&self) -> usize
fn word_count(&self) -> usize
Source§fn contains_exact_word(&self, word: &[char]) -> bool
fn contains_exact_word(&self, word: &[char]) -> bool
Source§fn contains_exact_word_str(&self, word: &str) -> bool
fn contains_exact_word_str(&self, word: &str) -> bool
Source§impl PartialEq for MutableDictionary
impl PartialEq for MutableDictionary
impl Eq for MutableDictionary
impl StructuralPartialEq for MutableDictionary
Auto Trait Implementations§
impl Freeze for MutableDictionary
impl RefUnwindSafe for MutableDictionary
impl Send for MutableDictionary
impl Sync for MutableDictionary
impl Unpin for MutableDictionary
impl UnwindSafe for MutableDictionary
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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>
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>
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