Struct nlprule::rules::Rules[][src]

pub struct Rules { /* fields omitted */ }

A set of grammatical error correction rules.

Implementations

impl Rules[src]

pub fn new<P: AsRef<Path>>(p: P) -> Result<Self, Error>[src]

Creates a new rules set from a path to a binary.

Errors

  • If the file can not be opened.
  • If the file content can not be deserialized to a rules set.

pub fn from_reader<R: Read>(reader: R) -> Result<Self, Error>[src]

Creates a new rules set from a reader.

pub fn rules(&self) -> &[Rule][src]

All rules ordered by priority.

pub fn rule(&self, id: &str) -> Option<&Rule>[src]

Finds a rule by ID.

pub fn apply(
    &self,
    tokens: &[Token<'_>],
    tokenizer: &Tokenizer
) -> Vec<Suggestion>
[src]

Compute the suggestions for the given tokens by checking all rules.

pub fn suggest(&self, text: &str, tokenizer: &Tokenizer) -> Vec<Suggestion>[src]

Compute the suggestions for a text by checking all rules.

pub fn correct(&self, text: &str, tokenizer: &Tokenizer) -> String[src]

Correct a text by first tokenizing, then finding all suggestions and choosing the first replacement of each suggestion.

pub fn iter(&self) -> RulesIter<'_>

Notable traits for RulesIter<'a>

impl<'a> Iterator for RulesIter<'a> type Item = &'a Rule;
[src]

A referential iterator.

Trait Implementations

impl Default for Rules[src]

impl<'de> Deserialize<'de> for Rules[src]

impl<R> FromIterator<R> for Rules where
    R: Into<Rule>, 
[src]

impl IntoIterator for Rules[src]

type Item = Rule

The type of the elements being iterated over.

type IntoIter = RulesIntoIter

Which kind of iterator are we turning this into?

impl Serialize for Rules[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.