find_match

Function find_match 

Source
pub fn find_match(
    haystack: &[Token],
    needle: &[Token],
    mode: MatchMode,
    permissive: bool,
) -> Option<MatchResult>
Expand description

Matches two Vecs of tokens based on MatchMode and returns the first match.

§Parameters

  • haystack - haystack to seek.
  • needle - needle to match.
  • mode - MatchMode to use for matching. See the enum for more info.
  • permissive - If haystack is more uppercased than needle, they will still match.

§Returns

§Example

use language_tokenizer::{MatchMode, Algorithm, find_match, tokenize};

let haystack = "that's someone who can rizz just like a skibidi! zoomer slang rocks, 67";
let needle = "like a skibidi";

let haystack = tokenize(haystack, Algorithm::English, false).unwrap();
let needle = tokenize(needle, Algorithm::English, false).unwrap();

assert!(find_match(&haystack, &needle, MatchMode::Exact, false).is_some());