The manga to evaluate
The match score (0-1)
The original search title
Current results array for context
OptionalkenmeiManga: KenmeiMangaOptional Kenmei manga for custom rule evaluation
Inclusion decision with potentially adjusted score
export function shouldIncludeMangaExact(
manga: AniListManga,
score: number,
searchTitle: string,
results: AniListManga[],
kenmeiManga?: KenmeiManga,
): InclusionResult {
console.debug(
`[MangaSearchService] 🔍 Checking titles for exact match against "${searchTitle}"`,
);
// Check custom accept rules if kenmeiManga provided
if (kenmeiManga) {
const { shouldAccept, matchedRule } = shouldAcceptByCustomRules(
manga,
kenmeiManga,
);
if (shouldAccept) {
console.debug(
`[MangaSearchService] ✅ Auto-accepting manga "${manga.title?.romaji || manga.title?.english}" due to custom rule: ${matchedRule?.description}`,
);
return {
shouldInclude: true,
adjustedScore: Math.max(score, ACCEPT_RULE_CONFIDENCE_FLOOR_EXACT), // Boost to high confidence
};
}
}
// In exact matching mode, do a thorough check of all titles
// This ensures we don't miss matches due to normalization differences
const foundGoodMatch = isExactMatch(manga, searchTitle);
if (score > 0.6 || foundGoodMatch || results.length <= 2) {
console.debug(
`[MangaSearchService] ✅ Including manga "${manga.title?.romaji || manga.title?.english}" with score: ${score}`,
);
return {
shouldInclude: true,
adjustedScore: foundGoodMatch
? Math.max(score, ACCEPT_RULE_CONFIDENCE_FLOOR_REGULAR)
: score,
};
} else {
console.debug(
`[MangaSearchService] ❌ Excluding manga "${manga.title?.romaji || manga.title?.english}" with score: ${score} (below threshold)`,
);
return { shouldInclude: false, adjustedScore: score };
}
}
Determines if a manga should be included in exact match results. Applies stricter thresholds (0.6+) and custom accept rules for priority inclusion.