Struct MutableDictionary

Source
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

Source

pub fn new() -> Self

Source

pub fn from_rune_files(word_list: &str, attr_list: &str) -> Result<Self, Error>

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> MutableDictionary

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MutableDictionary

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MutableDictionary

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Dictionary for MutableDictionary

Source§

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>

Get the associated WordMetadata for any capitalization of a given word.
Source§

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

Check if the dictionary contains any capitalization of a given word.
Source§

fn get_word_metadata_str(&self, word: &str) -> Option<&WordMetadata>

Get the associated WordMetadata for any capitalization of a given word. If the word isn’t in the dictionary, the resulting metadata will be empty.
Source§

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<'_>>

Gets best fuzzy match from dictionary
Source§

fn words_iter(&self) -> Box<dyn Iterator<Item = &[char]> + Send + '_>

Iterate over the words in the dictionary.
Source§

fn word_count(&self) -> usize

The number of words in the dictionary.
Source§

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

Check if the dictionary contains the exact capitalization of a given word.
Source§

fn get_word_from_id(&self, id: &WordId) -> Option<&[char]>

Returns the correct capitalization of the word with the given ID.
Source§

impl From<MutableDictionary> for FstDictionary

Source§

fn from(dict: MutableDictionary) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for MutableDictionary

Source§

fn eq(&self, other: &MutableDictionary) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for MutableDictionary

Source§

impl StructuralPartialEq for MutableDictionary

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> LSend for T
where T: ?Sized,