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 rule 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 new_with_options<P: AsRef<Path>>(
    p: P,
    options: RulesOptions
) -> Result<Self, Error>
[src]

Creates a new rule set with options. See new.

pub fn options(&self) -> &RulesOptions[src]

Gets the options of this rule set.

pub fn options_mut(&mut self) -> &mut RulesOptions[src]

Gets the options of this rule set (mutable).

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 rules_mut(&mut self) -> &mut [Rule][src]

All rules ordered by priority (mutable).

pub fn select<'a>(&'a self, selector: &'a Selector) -> RulesIter<'a>

Notable traits for RulesIter<'a>

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

Returns an iterator over all rules matching the selector.

pub fn select_mut<'a>(&'a mut self, selector: &'a Selector) -> RulesIterMut<'a>

Notable traits for RulesIterMut<'a>

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

Returns an iterator over all rules matching the selector (mutable).

pub fn apply(&self, sentence: &Sentence<'_>) -> Vec<Suggestion>[src]

Compute the suggestions for the given sentence 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.

Trait Implementations

impl Default for Rules[src]

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

impl Serialize for Rules[src]

Auto Trait Implementations

impl !RefUnwindSafe for Rules

impl Send for Rules

impl Sync for Rules

impl Unpin for Rules

impl UnwindSafe for Rules

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.