Dictionary

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 contains_exact_word(&self, word: &[char]) -> bool;
    fn contains_exact_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_correct_capitalization_of(&self, word: &[char]) -> Option<&[char]>;
    fn get_lexeme_metadata(
        &self,
        word: &[char],
    ) -> Option<Cow<'_, DictWordMetadata>>;
    fn get_lexeme_metadata_str(
        &self,
        word: &str,
    ) -> Option<Cow<'_, DictWordMetadata>>;
    fn words_iter(&self) -> Box<dyn Iterator<Item = &[char]> + Send + '_>;
    fn word_count(&self) -> usize;
    fn get_word_from_id(&self, id: &WordId) -> Option<&[char]>;
}
Expand description

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

See also: super::FstDictionary and super::MutableDictionary.

Required Methods§

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 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 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_correct_capitalization_of(&self, word: &[char]) -> Option<&[char]>

Source

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

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 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 get_word_from_id(&self, id: &WordId) -> Option<&[char]>

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

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 contains_exact_word(&self, word: &[char]) -> bool

Source§

fn contains_exact_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_correct_capitalization_of(&self, word: &[char]) -> Option<&[char]>

Source§

fn get_lexeme_metadata( &self, word: &[char], ) -> Option<Cow<'_, DictWordMetadata>>

Source§

fn get_lexeme_metadata_str( &self, word: &str, ) -> Option<Cow<'_, DictWordMetadata>>

Source§

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

Source§

fn word_count(&self) -> usize

Source§

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

Implementors§