score method

MatchResult score(
  1. String query,
  2. String title
)

Score a query against a title.

Implementation

MatchResult score(String query, String title) {
  if (query.length > title.length) return const MatchResult.noMatch();
  if (query.isEmpty) return _scoreEmpty(title);

  final queryLower = query.toLowerCase();
  final titleLower = title.toLowerCase();

  final (matchType, positions) = _detectMatchType(queryLower, titleLower);
  if (matchType == MatchType.noMatch) return const MatchResult.noMatch();

  return _computeScore(matchType, positions, queryLower, title);
}