Struct ngrammatic::NgramBuilder
source · [−]pub struct NgramBuilder { /* private fields */ }
Expand description
Build an Ngram
, one setting at a time.
Implementations
sourceimpl NgramBuilder
impl NgramBuilder
sourcepub fn new(text: &str) -> Self
pub fn new(text: &str) -> Self
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);
}
sourcepub fn pad_left(self, pad_left: Pad) -> Self
pub fn pad_left(self, pad_left: Pad) -> Self
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);
}
sourcepub fn pad_right(self, pad_right: Pad) -> Self
pub fn pad_right(self, pad_right: Pad) -> Self
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);
}
sourcepub fn pad_full(self, pad: Pad) -> Self
pub fn pad_full(self, pad: Pad) -> Self
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);
}
Trait Implementations
sourceimpl Debug for NgramBuilder
impl Debug for NgramBuilder
sourceimpl Default for NgramBuilder
impl Default for NgramBuilder
sourcefn default() -> NgramBuilder
fn default() -> NgramBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl RefUnwindSafe for NgramBuilder
impl Send for NgramBuilder
impl Sync for NgramBuilder
impl Unpin for NgramBuilder
impl UnwindSafe for NgramBuilder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more