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
Mutably borrows from an owned value. Read more
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> + 'a>
fn iter_matches<'a>( &'a self, tokens: &'a [Token], source: &'a [char], ) -> Box<dyn Iterator<Item = Span> + 'a>
Iterate over all matches of this expression in the document, automatically filtering out
overlapping matches, preferring the first.
fn iter_matches_in_doc<'a>( &'a self, doc: &'a Document, ) -> Box<dyn Iterator<Item = Span> + '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>
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