diff --git a/app/features/dictionary/transcribeSbgyXiaoyun.test.ts b/app/features/dictionary/transcribeSbgyXiaoyun.test.ts index b2a6889de..c8765be2d 100644 --- a/app/features/dictionary/transcribeSbgyXiaoyun.test.ts +++ b/app/features/dictionary/transcribeSbgyXiaoyun.test.ts @@ -1,10 +1,24 @@ +import { appendFileSync, writeFileSync } from "fs"; + import { getYuntuJson } from "prisma/external/getYuntuJson"; +import { files, readJsonSync } from "~/lib/files.server"; import { transcribeSbgyXiaoyun } from "./transcribeSbgyXiaoyun"; +const logOutputPath = __dirname + "/transcribeSbgyXiaoyun.test.log"; + describe("transcribeSbgyXiaoyun", () => { it("works with each xiaoyun of Guangyun", async () => { const yuntuJsons = await getYuntuJson(); + const sbgyJson = readJsonSync< + [ + syllableNumber: number, + fanqie: string, + onReading: string, + characters: string, + ][] + >(files.sbgyJson); + const xiaoyuns = Object.entries(yuntuJsons).map( ([xiaoyunNumber, yuntuJson]) => ({ xiaoyunNumber: +xiaoyunNumber, @@ -13,8 +27,10 @@ describe("transcribeSbgyXiaoyun", () => { tone: yuntuJson[2], kaihe: yuntuJson[3] || null, dengOrChongniu: yuntuJson[4] || null, + exemplars: sbgyJson[+xiaoyunNumber - 1][3], }), ); + writeFileSync(logOutputPath, ""); const failedTranscriptions = xiaoyuns.flatMap((xiaoyun) => { try { @@ -22,11 +38,29 @@ describe("transcribeSbgyXiaoyun", () => { const transcription = transcribeSbgyXiaoyun(xiaoyun); // eslint-disable-next-line @typescript-eslint/no-unused-vars const ascii = transcribeSbgyXiaoyun(xiaoyun, { ascii: true }); + appendFileSync( + logOutputPath, + `${xiaoyun.initial}${xiaoyun.cycleHead}${ + xiaoyun.dengOrChongniu || "" + }${xiaoyun.kaihe || ""}${xiaoyun.tone}`.padEnd(8) + + ` ${transcription.padEnd(7)} ,${xiaoyun.exemplars}\n`, + ); return []; } catch (error) { + appendFileSync( + logOutputPath, + `${xiaoyun.initial}${xiaoyun.cycleHead}${ + xiaoyun.dengOrChongniu || "" + }${xiaoyun.kaihe || ""}${xiaoyun.tone} ${error} ,${ + xiaoyun.exemplars + }\n`, + ); return { xiaoyun, error }; } }); + + console.log(`Wrote to ${logOutputPath}`); + expect(failedTranscriptions).toEqual([]); }); }); diff --git a/app/lib/qys/transcribeXiaoyun.ts b/app/lib/qys/transcribeXiaoyun.ts index d2a352f6e..ebc237757 100644 --- a/app/lib/qys/transcribeXiaoyun.ts +++ b/app/lib/qys/transcribeXiaoyun.ts @@ -429,7 +429,6 @@ export function transcribe( : transcribe韻母!(syllable); let initialRealization: string; - // if (母組 === "莊" && (韻 === "臻" || 等 === "二" || 韻 === "庚")) if ( 母組 === "莊" && // 2rd row or having underdot 臻庚 diff --git a/prisma/external/seedSbgy.ts b/prisma/external/seedSbgy.ts index 7825e3ea9..4e40959d4 100644 --- a/prisma/external/seedSbgy.ts +++ b/prisma/external/seedSbgy.ts @@ -114,6 +114,16 @@ async function getDbInput() { kaihe: yuntuJson[xiaoyunNumber][3] || null, dengOrChongniu: yuntuJson[xiaoyunNumber][4] || null, }; + + if ( + dbInput[xiaoyunNumber].cycleHead === "庚" && + dbInput[xiaoyunNumber].dengOrChongniu === "三" && + dbInput[xiaoyunNumber].initial === "生" && + dbInput[xiaoyunNumber].tone === "入" + ) { + // undoing inconsistency with Kan-on + dbInput[xiaoyunNumber].dengOrChongniu = "二"; + } } return dbInput; }