정답: 가수가 제목 정답에 섞이던 것·틀린 한글 발음 정답 고치기 (docs 13)

- 퀴즈 편집 화면: '추가 정답' 한 칸을 '제목 정답'·'가수 정답' 두 칸으로
- 괄호 안이 그 곡 가수 이름이면 제목 정답이 아님: cleanTitle(title, artist) — Crank That (Soulja Boy), 레이 (LAY). 정답 생성·플레이리스트·파일 읽기 모두 가수를 넘김
- 재생목록으로 엑셀 만들기: 정답·가수 정답 칸에 제목·가수를 다시 적지 않음(다른 표기만)
- 한글 발음 정답은 검수한 표기표(answers/lexicon.json: 단어 2,299·제목 74·가수 이름 1,111, 띄어 쓴 꼴과 붙여 쓴 꼴)만. 표기표에 없는 단어가 있으면 발음 정답 없이 unknownWords → 새 곡은 '확인 필요'(발음 확인 필요: …), 관리자 → 제목 정리에서 제목/가수 정답을 더해 적용. 규칙 읽기(en-ko.ts)는 후보·옛 정답 찾기에만
- cli redo-readings [--dry-run] [--old-lexicon]: 옛 규칙(이나 이전 표기표)이 만든 발음 정답만 빼고 표기표 표기로 — DB 별칭(source auto)과 일반 퀴즈 정답, 관리자 별칭·직접 쓴 정답·이지선다는 그대로. cli lexicon-missing: 표기표에 없는 단어와 규칙 후보
- 멜론 차트: 재생이 막힌 곡은 제목 칸에 링크가 없어 가수 링크를 제목으로 읽던 것 → 제목 칸만 읽음. cli fix-melon-titles: 제목이 가수 이름인 멜론 곡을 곡 정보 페이지 제목으로(자기 이름 곡은 그대로), 같은 곡이 이미 있으면 합침, 잘못 찾은 후보 영상은 원곡 찾기로
- decodeEntities: é·° 등(Céline Dion)
- 가수 칸의 따옴표 안을 with로 자르지 않음('Miki Matsubara Official "stay with me"' → 가수 정답 '미')
- 테스트: 표기표 읽기(사용자가 짚은 10곡 포함), 확인 필요로 보내기·정답 더해 적용, 발음 정답 바꾸기(DB·퀴즈·이지선다 제외·이전 표기표), 멜론 제목 칸·곡명·fix-melon-titles, 가수 괄호, 엑셀 칸; e2e quiz(재생목록 엑셀 칸)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-11-04 20:44:05 +09:00
parent 9a07b9978d
commit b360ff0eb7
24 changed files with 4166 additions and 54 deletions

View File

@@ -0,0 +1,71 @@
/** 발음 정답 다시 만들기 (2026-11-04, docs/13): old rule readings → the checked 한글 표기표, in the DB and in saved quizzes. */
import { expect, test } from 'bun:test';
import { openDb } from './db';
import { tempDbPath } from './test-utils';
import { Catalog } from './collector/catalog';
import { redoReadings } from './songs/readings-redo';
function aliases(db: ReturnType<typeof openDb>, id: number, part: string) {
return db
.query<{ alias: string }, [number, string]>('SELECT alias FROM song_aliases WHERE song_id = ? AND part = ? ORDER BY alias')
.all(id, part)
.map((r) => r.alias);
}
test('DB songs: the old reader\'s readings and the singer bracket go, checked spellings come, an admin alias stays', () => {
const db = openDb(tempDbPath());
const c = new Catalog(db);
const [rod] = c.upsert({ title: 'Heaven', artists: [{ name: 'Rod Stewart' }], source: 't', ref: '1' });
const [crank] = c.upsert({ title: 'Crank That', artists: [{ name: 'Soulja Boy' }], source: 't', ref: '2' });
const add = db.query('INSERT INTO song_aliases (song_id, part, alias, source) VALUES (?, ?, ?, ?)');
// what the 2026-11-04 cleanup wrote with the old rule reader
add.run(rod!, 'artist', '로드 스투어트', 'auto');
add.run(rod!, 'title', '헤벤', 'auto');
add.run(rod!, 'artist', '로드', 'admin');
db.query("INSERT INTO title_reviews (song_id, kind, status, old_title, old_artist, new_title, new_artist, title_answers, artist_answers, created_at) VALUES (?, 'title', 'applied', ?, ?, ?, ?, '[]', '[]', 0)").run(
crank!,
'Crank That (Soulja Boy)',
'Soulja Boy',
'Crank That',
'Soulja Boy',
);
for (const a of ['Crank That (Soulja Boy)', 'Crank That Soulja Boy', 'Soulja Boy', '솔야 보이', '크랭크 댓', '크랭크 댓 솔야 보이']) add.run(crank!, 'title', a, 'auto');
add.run(crank!, 'artist', '솔야 보이', 'auto');
const dry = redoReadings(db, { dryRun: true });
expect(dry.songs.changed).toBe(2);
expect(aliases(db, rod!, 'artist')).toEqual(['로드', '로드 스투어트']);
redoReadings(db);
expect(aliases(db, rod!, 'artist')).toEqual(['로드', '로드 스튜어트', '로드스튜어트']);
expect(aliases(db, rod!, 'title')).toEqual(['헤븐']);
// the old title as collected stays; the singer in its bracket and every reading of it go
expect(aliases(db, crank!, 'title')).toEqual(['Crank That (Soulja Boy)', '크랭크 댓', '크랭크댓']);
expect(aliases(db, crank!, 'artist')).toEqual(['솔자 보이', '솔자보이']);
// a second run changes nothing
expect(redoReadings(db).songs.changed).toBe(0);
// a 표기표 fix later: a spelling the table had before (not the rule reader's) goes only when that table is passed
const before = { words: { heaven: ['헤에븐'] }, titles: {}, artists: {} };
db.query("INSERT INTO song_aliases (song_id, part, alias, source) VALUES (?, 'title', '헤에븐', 'auto')").run(rod!);
expect(redoReadings(db).songs.changed).toBe(0);
expect(redoReadings(db, { oldTables: [before] }).songs.dropped).toBe(1);
expect(aliases(db, rod!, 'title')).toEqual(['헤븐']);
});
test('saved quizzes: generated readings replaced, typed answers kept, 이지선다 quizzes left alone', () => {
const db = openDb(tempDbPath());
db.query("INSERT INTO users (id, kind, nickname, created_at, last_seen_at) VALUES ('u', 'member', 'u', 0, 0)").run();
const normal = (db.query("INSERT INTO custom_quizzes (owner_id, name, description, visibility, settings_json, kind, created_at, updated_at) VALUES ('u', 'q', '', 'private', '{}', 'normal', 0, 0) RETURNING id").get() as { id: number }).id;
const duel = (db.query("INSERT INTO custom_quizzes (owner_id, name, description, visibility, settings_json, kind, created_at, updated_at) VALUES ('u', 'd', '', 'private', '{}', 'duel', 0, 0) RETURNING id").get() as { id: number }).id;
const item = db.query(
"INSERT INTO custom_quiz_items (quiz_id, pos, video_id, title, artist, title_answers, artist_answers) VALUES (?, ?, 'aaaaaaaaaaa', ?, ?, ?, ?) RETURNING id",
);
const a = (item.get(normal, 0, 'Dreamers', 'Jung Kook', JSON.stringify(['드리머즈 노래']), JSON.stringify(['융 쿠크', '정꾹이'])) as { id: number }).id;
const b = (item.get(duel, 0, 'Dreamers', 'Jung Kook', '[]', '[]') as { id: number }).id;
const r = redoReadings(db);
expect(r.quizItems.changed).toBe(1);
const got = (id: number) => db.query<{ t: string; a: string }, [number]>('SELECT title_answers t, artist_answers a FROM custom_quiz_items WHERE id = ?').get(id)!;
expect(JSON.parse(got(a).t)).toEqual(['드리머즈 노래', '드리머스', '드리머즈']);
expect(JSON.parse(got(a).a)).toEqual(['정꾹이', '정국']);
expect(got(b)).toEqual({ t: '[]', a: '[]' });
});