pub struct NgramBuilder { /* private fields */ }
Expand description

Build an Ngram, one setting at a time.

Implementations

Initialize a new instance of an NgramBuilder, with a default arity of 2, padding set to Auto, for the given text.

let a = NgramBuilder::new("tomato").arity(2).finish();
if a.contains("to") {
    println!("{} contains the bigram 'to'!", a.text);
}

Set the left padding to build into the Ngram.

let a = NgramBuilder::new("tomato").arity(2).pad_left(Pad::Pad(" ".to_string())).finish();
if a.contains(" t") {
    println!("{}, when padded, contains the bigram ' t'!", a.text);
}

Set the right padding to build into the Ngram.

let a = NgramBuilder::new("tomato").arity(2).pad_right(Pad::Pad(" ".to_string())).finish();
if a.contains("o ") {
    println!("{}, when padded, contains the bigram 'o '!", a.text);
}

Set both the left and right padding to build into the Ngram.

let a = NgramBuilder::new("tomato").arity(2).pad_full(Pad::Pad(" ".to_string())).finish();
if a.contains(" t") {
    println!("{}, when padded, contains the bigram ' t'!", a.text);
}
if a.contains("o ") {
    println!("{}, when padded, contains the bigram 'o '!", a.text);
}

Set arity (the n in ngram) to use for the resulting Ngram.

let a = NgramBuilder::new("tomato").arity(3).finish();
if a.contains("tom") {
    println!("{} contains the trigram 'tom'!", a.text);
}

Yield an Ngram instance with all the properties set with this builder.

let a = NgramBuilder::new("tomato").arity(3).finish();
if a.contains("tom") {
    println!("{} contains the trigram 'tom'!", a.text);
}

Trait Implementations

Formats the value using the given formatter. Read more

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.