Skip to content

Commit

Permalink
Typecheck
Browse files Browse the repository at this point in the history
  • Loading branch information
justinsilvestre committed Dec 8, 2023
1 parent 7a7d212 commit 8149f8a
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 139 deletions.
1 change: 0 additions & 1 deletion app/features/dictionary/DictionaryEntryComponentsTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ function DictionaryEntryComponentsTreeMember({
return (
<div className="relative flex flex-col">
<FigurePopoverBadge
id={componentFigure.id}
badgeProps={getBadgeProps(componentFigure)}
width={size === "large" ? 6 : 5}
className="mx-auto "
Expand Down
3 changes: 2 additions & 1 deletion app/features/dictionary/transcribeSbgyXiaoyun.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { appendFileSync, writeFileSync } from "fs";

import { getYuntuJson } from "prisma/external/getYuntuJson";
import { overrides } from "prisma/external/yuntuOverrides";
import { files, readJsonSync } from "~/lib/files.server";

import { transcribeSbgyXiaoyun } from "./transcribeSbgyXiaoyun";
Expand All @@ -9,7 +10,7 @@ const logOutputPath = __dirname + "/transcribeSbgyXiaoyun.test.log";

describe("transcribeSbgyXiaoyun", () => {
it("works with each xiaoyun of Guangyun", async () => {
const yuntuJsons = await getYuntuJson();
const yuntuJsons = await getYuntuJson(overrides);
const sbgyJson = readJsonSync<
[
syllableNumber: number,
Expand Down
34 changes: 34 additions & 0 deletions app/isComponentFirstClass.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,38 @@ import { isComponentFirstClass } from "prisma/kanjisense/isComponentFirstClass";
import { getFiguresToVariantGroups } from "prisma/kanjisense/seedKanjisenseFigures";
import { prisma } from "~/db.server";

import { ComponentUse } from "./features/dictionary/ComponentUse";

describe("isComponentFirstClass", () => {
const figuresToComponentTrees = new Map<string, ComponentUse[]>(
(
[
[
"歸",
[
["歸", "CDP-8CAB"],
["CDP-8CAB", "𠂤"],
["𠂤", "丿"],
["𠂤", "㠯"],
["CDP-8CAB", "止"],
["歸", "帚"],
["帚", "⺕"],
["帚", "冖"],
["帚", "巾"],
],
],
[
"𠚍",
[
["𠚍", "𠂭"],
["𠚍", "凵"],
],
],
["旡", []],
] as [string, [string, string][]][]
).map(([id, ct]) => [id, ct.map((c) => new ComponentUse(c[0], c[1]))]),
);

it("works with CDP-8CAB (left of 歸)", async () => {
const priorityFiguresIds = await prisma.kanjisenseFigure
.findMany({
Expand All @@ -23,6 +54,7 @@ describe("isComponentFirstClass", () => {
component,
componentsToDirectUsesPrimaryVariants,
figuresToVariantGroups,
figuresToComponentTrees,
);
expect(result).toEqual(false);
});
Expand All @@ -48,6 +80,7 @@ describe("isComponentFirstClass", () => {
component,
componentsToDirectUsesPrimaryVariants,
figuresToVariantGroups,
figuresToComponentTrees,
);
expect(result).toEqual(false);
});
Expand All @@ -73,6 +106,7 @@ describe("isComponentFirstClass", () => {
component,
componentsToDirectUsesPrimaryVariants,
figuresToVariantGroups,
figuresToComponentTrees,
);
expect(result).toEqual(true);
});
Expand Down
2 changes: 1 addition & 1 deletion app/routes/browse.atomic-components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ function FigureBadgeLink({
}) {
return (
<DictLink figureId={figureId} className={className}>
<FigureBadge id={figureId} badgeProps={badgeProps} />
<FigureBadge badgeProps={badgeProps} />
</DictLink>
);
}
Expand Down
2 changes: 1 addition & 1 deletion app/routes/browse.compound-components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ function FigureBadgeLink({
}) {
return (
<DictLink figureId={figureId}>
<FigureBadge id={figureId} badgeProps={badgeProps} />
<FigureBadge badgeProps={badgeProps} />
</DictLink>
);
}
Expand Down
2 changes: 1 addition & 1 deletion app/routes/browse.sound-components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ function FigureBadgeLink({
}) {
return (
<DictLink figureId={figureId}>
<FigureBadge id={figureId} badgeProps={badgeProps} />
<FigureBadge badgeProps={badgeProps} />
</DictLink>
);
}
Expand Down
30 changes: 2 additions & 28 deletions prisma/external/seedSbgy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { files, readJsonSync } from "~/lib/files.server";

import { registerSeeded } from "../seedUtils";

import { getYuntuJson, XiaoyunCategoriesJson } from "./getYuntuJson";
import { getYuntuJson } from "./getYuntuJson";
import { overrides } from "./yuntuOverrides";

// mostly ocr and xml structure corrections
const replacementFanqie = {
Expand Down Expand Up @@ -127,30 +128,3 @@ async function getDbInput() {
}
return dbInput;
}

export const overrides: Record<number, XiaoyunCategoriesJson> = {
// no homophones so no fanqie was given
1919: ["章", "蒸", "上", null, null], // 拯
3177: ["影", "銜", "去", null, null], // 𪒠

// rhyme classes differ from http://suzukish.s252.xrea.com/search/inkyo/yunzi/<CHARACTER>
// and in ytenx.org guangyun scans
392: ["並", "咍", "平", null, null], // 𤗏
400: ["滂", "咍", "平", null, null], // 𡜊
1452: ["滂", "咍", "上", null, null], // 啡 listed as homophonous to 俖; see next line
1458: ["幫", "咍", "上", null, null], // 俖 has unaspirated P yunjing, also Jiyun lists that as possible reading.
1456: ["明", "咍", "上", null, null], // 䆀
1465: ["並", "咍", "上", null, null], // 倍
2530: ["明", "咍", "去", null, null], // 䆀
2381: ["透", "齊", "去", "開", "三"], // 𥱻

// some atypical initial/final combos
// were made more typical
1310: ["泥", "之", "上", null, null], // 伱
2886: ["泥", "麻", "去", "開", "二"], //䏧
1871: ["端", "庚", "上", "開", "二"], // 打
574: ["從", "山", "平", "開", null], // 虥

// apparently corrections, judging by unt https://www.zhihu.com/question/490585553/answer/2157640006
1763: ["精", "歌", "上", "合", "一"], // 硰,
};
28 changes: 28 additions & 0 deletions prisma/external/yuntuOverrides.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { XiaoyunCategoriesJson } from "./getYuntuJson";

export const overrides: Record<number, XiaoyunCategoriesJson> = {
// no homophones so no fanqie was given
1919: ["章", "蒸", "上", null, null], // 拯
3177: ["影", "銜", "去", null, null], // 𪒠

// rhyme classes differ from http://suzukish.s252.xrea.com/search/inkyo/yunzi/<CHARACTER>
// and in ytenx.org guangyun scans
392: ["並", "咍", "平", null, null], // 𤗏
400: ["滂", "咍", "平", null, null], // 𡜊
1452: ["滂", "咍", "上", null, null], // 啡 listed as homophonous to 俖; see next line
1458: ["幫", "咍", "上", null, null], // 俖 has unaspirated P yunjing, also Jiyun lists that as possible reading.
1456: ["明", "咍", "上", null, null], // 䆀
1465: ["並", "咍", "上", null, null], // 倍
2530: ["明", "咍", "去", null, null], // 䆀
2381: ["透", "齊", "去", "開", "三"], // 𥱻

// some atypical initial/final combos
// were made more typical
1310: ["泥", "之", "上", null, null], // 伱
2886: ["泥", "麻", "去", "開", "二"], //䏧
1871: ["端", "庚", "上", "開", "二"], // 打
574: ["從", "山", "平", "開", null], // 虥

// apparently corrections, judging by unt https://www.zhihu.com/question/490585553/answer/2157640006
1763: ["精", "歌", "上", "合", "一"], // 硰,
};
106 changes: 0 additions & 106 deletions prisma/kanjisense/ComponentUseWithSignificance.ts

This file was deleted.

0 comments on commit 8149f8a

Please sign in to comment.