Trait Dictionary

Source
pub trait Dictionary: Send + Sync {
    // Required methods
    fn contains_word(&self, word: &[char]) -> bool;
    fn contains_word_str(&self, word: &str) -> bool;
    fn fuzzy_match(
        &self,
        word: &[char],
        max_distance: u8,
        max_results: usize,
    ) -> Vec<FuzzyMatchResult<'_>>;
    fn fuzzy_match_str(
        &self,
        word: &str,
        max_distance: u8,
        max_results: usize,
    ) -> Vec<FuzzyMatchResult<'_>>;
    fn get_word_metadata(&self, word: &[char]) -> WordMetadata;
    fn get_word_metadata_str(&self, word: &str) -> WordMetadata;
    fn words_iter(&self) -> Box<dyn Iterator<Item = &[char]> + Send + '_>;
    fn words_with_len_iter(
        &self,
        len: usize,
    ) -> Box<dyn Iterator<Item = &[char]> + Send + '_>;
}
Expand description

An in-memory database that contains everything necessary to parse and analyze English text.

See also: FstDictionary and FullDictionary.

Required Methods§

Source

fn contains_word(&self, word: &[char]) -> bool

Check if the dictionary contains a given word.

Source

fn contains_word_str(&self, word: &str) -> bool

Check if the dictionary contains a given word.

Source

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

Gets best fuzzy match from dictionary

Source

fn get_word_metadata(&self, word: &[char]) -> WordMetadata

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

Source

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

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

Source

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

Iterate over the words in the dictionary.

Source

fn words_with_len_iter( &self, len: usize, ) -> Box<dyn Iterator<Item = &[char]> + Send + '_>

Iterate over all the words in the dictionary of a given length

Implementations on Foreign Types§

Source§

impl<D: Dictionary + ?Sized> Dictionary for Arc<D>

Source§

fn contains_word(&self, word: &[char]) -> bool

Source§

fn contains_word_str(&self, word: &str) -> bool

Source§

fn fuzzy_match( &self, word: &[char], max_distance: u8, max_results: usize, ) -> Vec<FuzzyMatchResult<'_>>

Source§

fn fuzzy_match_str( &self, word: &str, max_distance: u8, max_results: usize, ) -> Vec<FuzzyMatchResult<'_>>

Source§

fn get_word_metadata(&self, word: &[char]) -> WordMetadata

Source§

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

Source§

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

Implementors§