pub struct StatisticalCorrector { /* private fields */ }Expand description
Statistical spelling corrector
Implementations§
Source§impl StatisticalCorrector
impl StatisticalCorrector
Sourcepub fn new(config: StatisticalCorrectorConfig) -> Self
pub fn new(config: StatisticalCorrectorConfig) -> Self
Create a new statistical spelling corrector with the given configuration
Sourcepub fn from_dictionary_corrector(dictcorrector: &DictionaryCorrector) -> Self
pub fn from_dictionary_corrector(dictcorrector: &DictionaryCorrector) -> Self
Create a statistical corrector from a base dictionary corrector
Sourcepub fn add_corpus_file<P: AsRef<Path>>(&mut self, path: P) -> Result<()>
pub fn add_corpus_file<P: AsRef<Path>>(&mut self, path: P) -> Result<()>
Add a corpus file to train the language model
Sourcepub fn add_trainingtext(&mut self, text: &str)
pub fn add_trainingtext(&mut self, text: &str)
Add text to train the language model
Sourcepub fn set_language_model(&mut self, model: NGramModel)
pub fn set_language_model(&mut self, model: NGramModel)
Set the language model
Sourcepub fn set_error_model(&mut self, model: ErrorModel)
pub fn set_error_model(&mut self, model: ErrorModel)
Set the error model
Sourcepub fn set_metric<M: StringMetric + Send + Sync + 'static>(&mut self, metric: M)
pub fn set_metric<M: StringMetric + Send + Sync + 'static>(&mut self, metric: M)
Set the string metric to use for similarity calculations
Sourcepub fn set_config(&mut self, config: StatisticalCorrectorConfig)
pub fn set_config(&mut self, config: StatisticalCorrectorConfig)
Set the configuration
Sourcepub fn correct_sentence(&self, sentence: &str) -> Result<String>
pub fn correct_sentence(&self, sentence: &str) -> Result<String>
Correct a sentence using a context-aware approach
Sourcepub fn remove_word(&mut self, word: &str)
pub fn remove_word(&mut self, word: &str)
Remove a word from the dictionary
Sourcepub fn dictionary_size(&self) -> usize
pub fn dictionary_size(&self) -> usize
Get the total number of words in the dictionary
Sourcepub fn vocabulary_size(&self) -> usize
pub fn vocabulary_size(&self) -> usize
Get the vocabulary size of the language model
Trait Implementations§
Source§impl Clone for StatisticalCorrector
impl Clone for StatisticalCorrector
Source§impl Debug for StatisticalCorrector
impl Debug for StatisticalCorrector
Source§impl Default for StatisticalCorrector
impl Default for StatisticalCorrector
Source§impl SpellingCorrector for StatisticalCorrector
impl SpellingCorrector for StatisticalCorrector
Auto Trait Implementations§
impl Freeze for StatisticalCorrector
impl !RefUnwindSafe for StatisticalCorrector
impl Send for StatisticalCorrector
impl Sync for StatisticalCorrector
impl Unpin for StatisticalCorrector
impl UnsafeUnpin for StatisticalCorrector
impl !UnwindSafe for StatisticalCorrector
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.