Skip to content

Commit

Permalink
Tweak yuntu categories
Browse files Browse the repository at this point in the history
  • Loading branch information
justinsilvestre committed Nov 28, 2023
1 parent 7cb7a3d commit fa08b91
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
34 changes: 34 additions & 0 deletions app/features/dictionary/transcribeSbgyXiaoyun.test.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -13,20 +27,40 @@ 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 {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
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([]);
});
});
1 change: 0 additions & 1 deletion app/lib/qys/transcribeXiaoyun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,6 @@ export function transcribe(
: transcribe韻母!(syllable);

let initialRealization: string;
// if (母組 === "莊" && (韻 === "臻" || 等 === "二" || 韻 === "庚"))
if (
母組 === "莊" &&
// 2rd row or having underdot 臻庚
Expand Down
10 changes: 10 additions & 0 deletions prisma/external/seedSbgy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit fa08b91

Please sign in to comment.