-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexport.ts
More file actions
222 lines (212 loc) · 7.47 KB
/
export.ts
File metadata and controls
222 lines (212 loc) · 7.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
import { Dictionary, DictionaryIndex } from "yomichan-dict-builder";
import { addTermsMoe } from "./moe_dics.ts";
import { addTermsLiangAn } from "./liangan.ts";
const versions = {
moeConcised: "2026/02/06.1",
moeRevised: "2026/01/30.2",
liangAn: "2026/01/27.1",
};
// for the concised and revised moe dictionaries
const addSynonymsAntonyms = true;
// makes it so these dictionaries are prioritized in the search results (because they have some sort of frequency sort for the 多音字)
const popularityBoost = 100;
const [
zhuyinConcisedDic,
pinyinConcisedDic,
zhuyinRevisedDic,
pinyinRevisedDic,
liangAnDicZhuyin,
liangAnDicPinyin,
] = await initDics();
await addTermsMoe(
[zhuyinConcisedDic, pinyinConcisedDic, zhuyinRevisedDic, pinyinRevisedDic],
[
"dict/dict_concised_2014_20250925.xlsx",
"dict/dict_revised_2015_20251229.xlsx",
"dict/dict_concised_pic_2014_20250925.xlsx",
"dict/dict_concised_pic_2014_20250925",
],
addSynonymsAntonyms,
popularityBoost,
);
for (const f of [
zhuyinConcisedDic,
pinyinConcisedDic,
zhuyinRevisedDic,
pinyinRevisedDic,
liangAnDicZhuyin,
liangAnDicPinyin,
]) {
await f.addFile("./styles.css", "styles.css");
}
console.log("Exporting MOE dictionaries...");
await zhuyinConcisedDic.export("build");
console.log("Exported 國語辭典簡編本 注音");
await pinyinConcisedDic.export("build");
console.log("Exported 國語辭典簡編本 拼音");
await zhuyinRevisedDic.export("build");
console.log("Exported 重編國語辭典修訂本 注音");
await pinyinRevisedDic.export("build");
console.log("Exported 重編國語辭典修訂本 拼音");
await addTermsLiangAn(
[liangAnDicZhuyin, liangAnDicPinyin],
"dict/liangancidian.xlsx",
popularityBoost,
);
console.log("Exporting LiangAn dictionary...");
await liangAnDicZhuyin.export("build");
console.log("Exported 兩岸詞典 注音");
await liangAnDicPinyin.export("build");
console.log("Exported 兩岸詞典 拼音");
export async function initDics(): Promise<
[Dictionary, Dictionary, Dictionary, Dictionary, Dictionary, Dictionary]
> {
const zhuyinConcisedDic = new Dictionary({
fileName: "moe-concised-zhuyin.zip",
});
const pinyinConcisedDic = new Dictionary({
fileName: "moe-concised-pinyin.zip",
});
const zhuyinRevisedDic = new Dictionary({
fileName: "moe-revised-zhuyin.zip",
});
const pinyinRevisedDic = new Dictionary({
fileName: "moe-revised-pinyin.zip",
});
const zhuyinIndexConcised = new DictionaryIndex()
.setTitle("國語辭典簡編本 注音")
.setRevision(versions.moeConcised)
.setAuthor("shadow")
.setAttribution("國語辭典簡編本 (2014)")
.setDescription(
"A monolingual dictionary made for learners of Mandarin Chinese. 主要適用對象:國中、小學生及學習華語人士。",
)
.setIsUpdatable(true)
.setIndexUrl(
"https://github.com/username-011/moe-dict-yomitan/releases/latest/download/index-concised-zhuyin.json",
)
.setDownloadUrl(
"https://github.com/username-011/moe-dict-yomitan/releases/latest/download/moe-concised-zhuyin.zip",
);
zhuyinIndexConcised.index.sourceLanguage = "zh";
zhuyinIndexConcised.index.targetLanguage = "zh";
const pinyinIndexConcised = new DictionaryIndex()
.setTitle("國語辭典簡編本 拼音")
.setRevision(versions.moeConcised)
.setAuthor("shadow")
.setAttribution("國語辭典簡編本 (2014)")
.setDescription(
"A monolingual dictionary made for learners of Mandarin Chinese. 主要適用對象:國中、小學生及學習華語人士。",
)
.setIsUpdatable(true)
.setIndexUrl(
"https://github.com/username-011/moe-dict-yomitan/releases/latest/download/index-concised-pinyin.json",
)
.setDownloadUrl(
"https://github.com/username-011/moe-dict-yomitan/releases/latest/download/moe-concised-pinyin.zip",
);
pinyinIndexConcised.index.sourceLanguage = "zh";
pinyinIndexConcised.index.targetLanguage = "zh";
await zhuyinConcisedDic.setIndex(
zhuyinIndexConcised.build(),
"build",
"index-concised-zhuyin.json",
);
await pinyinConcisedDic.setIndex(
pinyinIndexConcised.build(),
"build",
"index-concised-pinyin.json",
);
await zhuyinRevisedDic.setIndex(
zhuyinIndexConcised
.setTitle("重編國語辭典修訂本 注音")
.setRevision(versions.moeRevised)
.setDescription(
"A monolingual dictionary made for Mandarin Chinese. 主要適用對象:對歷史語言有興趣的研究者。",
)
.setAttribution("重編國語辭典修訂本 (2015)")
.setIsUpdatable(true)
.setIndexUrl(
"https://github.com/username-011/moe-dict-yomitan/releases/latest/download/index-revised-zhuyin.json",
)
.setDownloadUrl(
"https://github.com/username-011/moe-dict-yomitan/releases/latest/download/moe-revised-zhuyin.zip",
)
.build(),
"build",
"index-revised-zhuyin.json",
);
await pinyinRevisedDic.setIndex(
pinyinIndexConcised
.setTitle("重編國語辭典修訂本 拼音")
.setRevision(versions.moeRevised)
.setDescription(
"A monolingual dictionary made for Mandarin Chinese. 主要適用對象:對歷史語言有興趣的研究者。",
)
.setIsUpdatable(true)
.setIndexUrl(
"https://github.com/username-011/moe-dict-yomitan/releases/latest/download/index-revised-pinyin.json",
)
.setDownloadUrl(
"https://github.com/username-011/moe-dict-yomitan/releases/latest/download/moe-revised-pinyin.zip",
)
.setAttribution("重編國語辭典修訂本 (2015)")
.build(),
"build",
"index-revised-pinyin.json",
);
const liangAnDicZhuyin = new Dictionary({
fileName: "liangancidian-zhuyin.zip",
});
const liangAnDicPinyin = new Dictionary({
fileName: "liangancidian-pinyin.zip",
});
const zhuyinIndexLiangAn = new DictionaryIndex()
.setTitle("兩岸詞典 注音")
.setRevision(versions.liangAn)
.setAuthor("shadow")
.setAttribution("兩岸詞典 (2015)")
.setDescription("A monolingual dictionary of Mandarin Chinese.")
.setIsUpdatable(true)
.setIndexUrl(
"https://github.com/username-011/moe-dict-yomitan/releases/latest/download/index-liangancidian-zhuyin.json",
)
.setDownloadUrl(
"https://github.com/username-011/moe-dict-yomitan/releases/latest/download/liangancidian-zhuyin.zip",
);
zhuyinIndexLiangAn.index.sourceLanguage = "zh";
zhuyinIndexLiangAn.index.targetLanguage = "zh";
const pinyinIndexLiangAn = new DictionaryIndex()
.setTitle("兩岸詞典 拼音")
.setRevision(versions.liangAn)
.setAuthor("shadow")
.setAttribution("兩岸詞典 (2015)")
.setDescription("A monolingual dictionary of Mandarin Chinese.")
.setIsUpdatable(true)
.setIndexUrl(
"https://github.com/username-011/moe-dict-yomitan/releases/latest/download/index-liangancidian-pinyin.json",
)
.setDownloadUrl(
"https://github.com/username-011/moe-dict-yomitan/releases/latest/download/liangancidian-pinyin.zip",
);
pinyinIndexLiangAn.index.sourceLanguage = "zh";
pinyinIndexLiangAn.index.targetLanguage = "zh";
await liangAnDicZhuyin.setIndex(
zhuyinIndexLiangAn.build(),
"build",
"index-liangancidian-zhuyin.json",
);
await liangAnDicPinyin.setIndex(
pinyinIndexLiangAn.build(),
"build",
"index-liangancidian-pinyin.json",
);
return [
zhuyinConcisedDic,
pinyinConcisedDic,
zhuyinRevisedDic,
pinyinRevisedDic,
liangAnDicZhuyin,
liangAnDicPinyin,
];
}