The Kenmei manga entry to score.
The AniList manga entry to compare against.
Match confidence score between 0 and 1, where 1 is a perfect match.
export function scoreMatch(
kenmeiManga: KenmeiManga,
anilistManga: AniListManga,
): number {
const title = kenmeiManga.title?.toLowerCase() ?? "";
if (!title) return 0;
// Compare against all available AniList titles and return highest score
const candidateTitles = [
anilistManga.title?.romaji,
anilistManga.title?.english,
anilistManga.title?.native,
];
let best = 0;
for (const candidate of candidateTitles) {
if (!candidate) continue;
const score = calculateSimilarity(title, candidate);
if (score > best) best = score;
// Short-circuit on perfect match
if (best >= 1) return 1;
}
return best;
}
Score a match between Kenmei and AniList manga by comparing available titles.