search method
Executes a search, given a search string
Implementation
MatchScore search(String text) {
if (!options.isCaseSensitive) {
text = text.toLowerCase();
}
if (options.shouldNormalize) {
text = text.latinize();
}
// Exact match
if (pattern == text) {
return MatchScore(
isMatch: true,
score: 0,
matchedIndices: [MatchIndex(0, text.length - 1)],
);
}
// When pattern length is greater than the machine word length, just do a a regex comparison
if (pattern.length > options.maxPatternLength) {
return bitapRegexSearch(text, pattern, options.tokenSeparator);
}
// Otherwise, use Bitap algorithm
return bitapSearch(
text,
pattern,
patternAlphabet,
location: options.location,
distance: options.distance,
threshold: options.threshold,
findAllMatches: options.findAllMatches,
minMatchCharLength: options.minMatchCharLength,
);
}