정답 자동 생성: 한국어 제목에 한자 별칭이 붙은 곡(몽(夢))을 일본어 제목으로 보고 위키백과 이름(꿈)으로 바꾸던 것 — 괄호 밖 원제가 일본어일 때만 일본어 제목으로 다룸. 회귀 테스트(고치기 전 실패 확인), 夜に駆ける (밤에 달리다) → 밤을 달리다 테스트 유지

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-11-04 16:21:49 +09:00
parent 04da87562b
commit 7385ae4b72
2 changed files with 11 additions and 1 deletions

View File

@@ -154,3 +154,11 @@ test('플레이리스트 가져오기: the answers come from the title as found
expect(job.rows[1]!.title).toBe('밤을 달리다');
expect(job.rows[1]!.titleAnswers).toEqual(expect.arrayContaining(['夜に駆ける', '요루니 카케루', '요루니 가케루']));
});
test('a Korean title with a 한자 alias ("몽(夢)") is never renamed, even when Wikipedia knows the 한자', async () => {
const wiki = async (names: string[]) => new Map<string, string>(names.includes('夢') ? [['夢', '꿈']] : []);
const [a] = await songAnswersBatch(null, [{ title: '몽(夢)', artist: '가수' }], { korean: true, wiki });
expect(a).toMatchObject({ title: '몽', note: null });
expect(a!.titleAnswers).toContain('夢');
expect(a!.titleAnswers).not.toContain('꿈');
});

View File

@@ -114,7 +114,9 @@ export async function songAnswersBatch(db: Database | null, songs: { title: stri
};
// the Japanese title: shown as is, or already swapped for its bracket's Korean name by cleanTitle
// ("夜に駆ける (밤에 달리다)") — Wikipedia still goes first, so the order is decided on the original
const jaTitle = hasJapanese(c.title) ? c.title : c.aliases.find((a) => hasJapanese(a));
// only when the title outside the brackets was Japanese: "몽(夢)" is a Korean title with a 한자 alias, never renamed
const outsideJa = hasJapanese(s.title.replace(/[([{([【「『][^)\]})]】」』]*[)\]})]】」』]/g, ' '));
const jaTitle = hasJapanese(c.title) ? c.title : outsideJa ? c.aliases.find((a) => hasJapanese(a)) : undefined;
if (opts.korean && jaTitle) {
const bracket = hasJapanese(c.title) ? c.aliases.find((a) => HANGUL.test(a) && !hasJapanese(a)) : c.title;
title = korean(jaTitle, bracket, extraTitle);