pub struct FixedPhrase { /* private fields */ }
Expand description
Matches a fixed sequence of tokens as they appear in the input. Case-insensitive for words but maintains exact matching for other token types.
§Example
use harper_core::patterns::{FixedPhrase, Pattern};
use harper_core::Document;
let doc = Document::new_plain_english_curated("Hello, world!");
let phrase = FixedPhrase::from_phrase("Hello, world!");
assert!(phrase.matches(doc.get_tokens(), doc.get_source()).is_some());
Implementations§
Source§impl FixedPhrase
impl FixedPhrase
Sourcepub fn from_phrase(text: &str) -> Self
pub fn from_phrase(text: &str) -> Self
Creates a FixedPhrase from a plain text string. Uses plain English tokenization rules.
Sourcepub fn from_document(doc: &Document) -> Self
pub fn from_document(doc: &Document) -> Self
Creates a FixedPhrase from a pre-tokenized document.
Allows custom tokenization by creating a Document
first.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FixedPhrase
impl !RefUnwindSafe for FixedPhrase
impl !Send for FixedPhrase
impl !Sync for FixedPhrase
impl Unpin for FixedPhrase
impl !UnwindSafe for FixedPhrase
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<P> DocPattern for Pwhere
P: PatternExt,
impl<P> DocPattern for Pwhere
P: PatternExt,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more