pub struct OfflineProvider { /* private fields */ }Expand description
The bundled offline correction provider.
Wraps spellbook, a pure-Rust, Hunspell-compatible spell-checker,
over an English dictionary. Fully local and instant — this is the
provider behind fix-word. Contextual fixes route elsewhere.
Implementations§
Source§impl OfflineProvider
impl OfflineProvider
Sourcepub fn from_hunspell(aff: &str, dic: &str) -> Result<Self, Error>
pub fn from_hunspell(aff: &str, dic: &str) -> Result<Self, Error>
Build the provider from Hunspell .aff and .dic data.
§Errors
Returns Error::Init if the dictionary fails to parse.
Sourcepub fn en_us() -> Result<Self, Error>
pub fn en_us() -> Result<Self, Error>
Build the provider from the bundled en_US dictionary.
The dictionary is vendored from wooorm/dictionaries (the en
dictionary, derived from SCOWL) and embedded at compile time; its
license is at dictionaries/en_US/LICENSE.
§Errors
Returns Error::Init if the bundled dictionary fails to parse,
which would indicate a packaging bug.
Sourcepub fn check_text(&self, text: &str) -> Vec<Correction>
pub fn check_text(&self, text: &str) -> Vec<Correction>
Spell-check text, returning one Correction per misspelled
word. This is the synchronous core behind the async trait method.
Trait Implementations§
Source§impl CorrectionProvider for OfflineProvider
impl CorrectionProvider for OfflineProvider
Source§fn check<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
text: &'life1 str,
_ctx: &'life2 Context,
) -> Pin<Box<dyn Future<Output = Result<Vec<Correction>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn check<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
text: &'life1 str,
_ctx: &'life2 Context,
) -> Pin<Box<dyn Future<Output = Result<Vec<Correction>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
text and return the corrections this provider would make. Read more