Skip to main content

SymSpell

Struct SymSpell 

Source
pub struct SymSpell<T: StringStrategy> { /* private fields */ }

Implementations§

Source§

impl<T: StringStrategy> SymSpell<T>

Source

pub fn load_dictionary( &mut self, corpus: &str, term_index: i64, count_index: i64, separator: &str, ) -> bool

Load multiple dictionary entries from a file of word/frequency count pairs.

§Arguments
  • corpus - The path+filename of the file.
  • term_index - The column position of the word.
  • count_index - The column position of the frequency count.
  • separator - Separator between word and frequency
Source

pub fn load_dictionary_line( &mut self, line: &str, term_index: i64, count_index: i64, separator: &str, ) -> bool

Load single dictionary entry from word/frequency count pair.

§Arguments
  • line - word/frequency pair.
  • term_index - The column position of the word.
  • count_index - The column position of the frequency count.
  • separator - Separator between word and frequency
Source

pub fn load_bigram_dictionary( &mut self, corpus: &str, term_index: i64, count_index: i64, separator: &str, ) -> bool

Load multiple bigram entries from a file of bigram/frequency count pairs.

§Arguments
  • corpus - The path+filename of the file.
  • term_index - The column position of the word.
  • count_index - The column position of the frequency count.
  • separator - Separator between word and frequency
Source

pub fn load_bigram_dictionary_line( &mut self, line: &str, term_index: i64, count_index: i64, separator: &str, ) -> bool

Load single dictionary entry from bigram/frequency count pair.

§Arguments
  • line - bigram/frequency pair.
  • term_index - The column position of the word.
  • count_index - The column position of the frequency count.
  • separator - Separator between word and frequency
Source

pub fn lookup( &self, input: &str, verbosity: Verbosity, max_edit_distance: i64, ) -> Vec<Suggestion>

Find suggested spellings for a given input word, using the maximum edit distance specified during construction of the SymSpell dictionary.

§Arguments
  • input - The word being spell checked.
  • verbosity - The value controlling the quantity/closeness of the retuned suggestions.
  • max_edit_distance - The maximum edit distance between input and suggested words.
§Examples
use symspell::{SymSpell, AsciiStringStrategy, Verbosity};

let mut symspell: SymSpell<AsciiStringStrategy> = SymSpell::default();
symspell.load_dictionary("data/frequency_dictionary_en_82_765.txt", 0, 1, " ");
symspell.lookup("whatver", Verbosity::Top, 2);
Source

pub fn lookup_compound( &self, input: &str, edit_distance_max: i64, ) -> Vec<Suggestion>

Find suggested spellings for a given input sentence, using the maximum edit distance specified during construction of the SymSpell dictionary.

§Arguments
  • input - The sentence being spell checked.
  • max_edit_distance - The maximum edit distance between input and suggested words.
§Examples
use symspell::{SymSpell, AsciiStringStrategy};

let mut symspell: SymSpell<AsciiStringStrategy> = SymSpell::default();
symspell.load_dictionary("data/frequency_dictionary_en_82_765.txt", 0, 1, " ");
symspell.lookup_compound("whereis th elove", 2);
Source

pub fn word_segmentation( &self, input: &str, max_edit_distance: i64, ) -> Composition

Divides a string into words by inserting missing spaces at the appropriate positions

§Arguments
  • input - The word being segmented.
  • max_edit_distance - The maximum edit distance between input and suggested words.
§Examples
use symspell::{SymSpell, UnicodeStringStrategy, Verbosity};

let mut symspell: SymSpell<UnicodeStringStrategy> = SymSpell::default();
symspell.load_dictionary("data/frequency_dictionary_en_82_765.txt", 0, 1, " ");
symspell.word_segmentation("itwas", 2);

Trait Implementations§

Source§

impl<T: StringStrategy> Default for SymSpell<T>

Source§

fn default() -> SymSpell<T>

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

impl<T: PartialEq + StringStrategy> PartialEq for SymSpell<T>

Source§

fn eq(&self, other: &SymSpell<T>) -> 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<T: StringStrategy> StructuralPartialEq for SymSpell<T>

Auto Trait Implementations§

§

impl<T> Freeze for SymSpell<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for SymSpell<T>
where T: RefUnwindSafe,

§

impl<T> Send for SymSpell<T>
where T: Send,

§

impl<T> Sync for SymSpell<T>
where T: Sync,

§

impl<T> Unpin for SymSpell<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for SymSpell<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for SymSpell<T>
where T: UnwindSafe,

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