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::expr::{FixedPhrase, Expr};
use harper_core::Document;
let doc = Document::new_plain_english_curated("Hello, world!");
let phrase = FixedPhrase::from_phrase("Hello, world!");
assert!(phrase.run(0, 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 plaintext 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
Source§impl<E> ExprExt for E
impl<E> ExprExt for E
Source§fn iter_matches<'a>(
&'a self,
tokens: &'a [Token],
source: &'a [char],
) -> Box<dyn Iterator<Item = Span<Token>> + 'a>
fn iter_matches<'a>( &'a self, tokens: &'a [Token], source: &'a [char], ) -> Box<dyn Iterator<Item = Span<Token>> + 'a>
fn iter_matches_in_doc<'a>( &'a self, doc: &'a Document, ) -> Box<dyn Iterator<Item = Span<Token>> + 'a>
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>
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>
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 moreSource§impl<E> OwnedExprExt for Ewhere
E: Expr + 'static,
impl<E> OwnedExprExt for Ewhere
E: Expr + 'static,
Source§fn or(self, other: impl Expr + 'static) -> FirstMatchOf
fn or(self, other: impl Expr + 'static) -> FirstMatchOf
Returns an expression that matches either the current one or the expression contained in other.
Source§fn and(self, other: impl Expr + 'static) -> All
fn and(self, other: impl Expr + 'static) -> All
Returns an expression that matches only if both the current one and the expression contained in other do.
Source§fn and_not(self, other: impl Expr + 'static) -> All
fn and_not(self, other: impl Expr + 'static) -> All
Returns an expression that matches only if the current one matches and the expression contained in other does not.
Source§fn or_longest(self, other: impl Expr + 'static) -> LongestMatchOf
fn or_longest(self, other: impl Expr + 'static) -> LongestMatchOf
Returns an expression that matches the longest of the current one or the expression contained in other.
If you don’t need the longest match, prefer using the short-circuiting [Self::or()] instead.