-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexport.ts
More file actions
144 lines (136 loc) · 5.02 KB
/
export.ts
File metadata and controls
144 lines (136 loc) · 5.02 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
import { addFiles, readTermsFromFile } from "./dics/shared.ts";
import { Dictionary, DictionaryIndex } from "yomichan-dict-builder";
import { processGuifan } from "./dics/guifan/guifan.ts";
import { processHanyu7 } from "./dics/hanyu7/hanyu7.ts";
import { mergeCssFiles } from "./utils/css.ts";
const versions = {
guifan: "2026/02/12.1",
hanyu7: "2026/02/09.1",
};
const guifanPinyinDic = new Dictionary({ fileName: "guifan-pinyin.zip" });
const guifanZhuyinDic = new Dictionary({ fileName: "guifan-zhuyin.zip" });
const guifanPinyinIndex = new DictionaryIndex()
.setTitle("现代汉语规范词典 拼音")
.setRevision(versions.guifan)
.setAuthor("shadow")
.setAttribution("外语教学与研究出版社 (2010)")
.setDescription("A monolingual dictionary of Simplified Mandarin Chinese.")
.setIsUpdatable(true)
.setIndexUrl(
"https://github.com/username-011/mdx-yomitan/releases/latest/download/index-guifan-pinyin.json",
)
.setDownloadUrl(
"https://github.com/username-011/mdx-yomitan/releases/latest/download/guifan-pinyin.zip",
);
guifanPinyinIndex.index.sourceLanguage = "zh";
guifanPinyinIndex.index.targetLanguage = "zh";
const guifanZhuyinIndex = new DictionaryIndex()
.setTitle("现代汉语规范词典 注音")
.setRevision(versions.guifan)
.setAuthor("shadow")
.setAttribution("外语教学与研究出版社 (2010)")
.setDescription("A monolingual dictionary of Simplified Mandarin Chinese.")
.setIsUpdatable(true)
.setIndexUrl(
"https://github.com/username-011/mdx-yomitan/releases/latest/download/index-guifan-zhuyin.json",
)
.setDownloadUrl(
"https://github.com/username-011/mdx-yomitan/releases/latest/download/guifan-zhuyin.zip",
);
guifanZhuyinIndex.index.sourceLanguage = "zh";
guifanZhuyinIndex.index.targetLanguage = "zh";
await guifanPinyinDic.setIndex(
guifanPinyinIndex.build(),
"build",
"index-guifan-pinyin.json",
);
await guifanZhuyinDic.setIndex(
guifanZhuyinIndex.build(),
"build",
"index-guifan-zhuyin.json",
);
const hanyu7PinyinDic = new Dictionary({ fileName: "hanyu7-pinyin.zip" });
const hanyu7ZhuyinDic = new Dictionary({ fileName: "hanyu7-zhuyin.zip" });
const hanyu7PinyinIndex = new DictionaryIndex()
.setTitle("现代汉语词典 拼音")
.setRevision(versions.hanyu7)
.setAuthor("shadow")
.setAttribution("外语教学与研究出版社 (2016)")
.setDescription("A monolingual dictionary of Simplified Mandarin Chinese.")
.setIsUpdatable(true)
.setIndexUrl(
"https://github.com/username-011/mdx-yomitan/releases/latest/download/index-hanyu7-pinyin.json",
)
.setDownloadUrl(
"https://github.com/username-011/mdx-yomitan/releases/latest/download/hanyu7-pinyin.zip",
);
hanyu7PinyinIndex.index.sourceLanguage = "zh";
hanyu7PinyinIndex.index.targetLanguage = "zh";
const hanyu7ZhuyinIndex = new DictionaryIndex()
.setTitle("现代汉语词典 注音")
.setRevision(versions.hanyu7)
.setAuthor("shadow")
.setAttribution("外语教学与研究出版社 (2016)")
.setDescription("A monolingual dictionary of Simplified Mandarin Chinese.")
.setIsUpdatable(true)
.setIndexUrl(
"https://github.com/username-011/mdx-yomitan/releases/latest/download/index-hanyu7-zhuyin.json",
)
.setDownloadUrl(
"https://github.com/username-011/mdx-yomitan/releases/latest/download/hanyu7-zhuyin.zip",
);
hanyu7ZhuyinIndex.index.sourceLanguage = "zh";
hanyu7ZhuyinIndex.index.targetLanguage = "zh";
await hanyu7PinyinDic.setIndex(
hanyu7PinyinIndex.build(),
"build",
"index-hanyu7-pinyin.json",
);
await hanyu7ZhuyinDic.setIndex(
hanyu7ZhuyinIndex.build(),
"build",
"index-hanyu7-zhuyin.json",
);
await processGuifan(
readTermsFromFile(
`data/mdx-guifan-2/mdx/【现代汉语规范词典(第2版)】.mdx.txt`,
),
[guifanPinyinDic, guifanZhuyinDic],
);
await addFiles([hanyu7PinyinDic, hanyu7ZhuyinDic], "data/mdx-7/mdd");
await processHanyu7(readTermsFromFile(`data/mdx-7/mdx/现汉7.mdx.txt`), [
hanyu7PinyinDic,
hanyu7ZhuyinDic,
]);
mergeCssFiles(
["styles-guifan.css", "styles-guifan-pinyin-diff.css"],
"styles-guifan-pinyin.css",
);
mergeCssFiles(
["styles-guifan.css", "styles-guifan-zhuyin-diff.css"],
"styles-guifan-zhuyin.css",
);
mergeCssFiles(
["styles-hanyu7.css", "styles-hanyu7-pinyin-diff.css"],
"styles-hanyu7-pinyin.css",
);
mergeCssFiles(
["styles-hanyu7.css", "styles-hanyu7-zhuyin-diff.css"],
"styles-hanyu7-zhuyin.css",
);
await Promise.all([
guifanPinyinDic.addFile("./styles-guifan-pinyin.css", "styles.css"),
guifanZhuyinDic.addFile("./styles-guifan-zhuyin.css", "styles.css"),
]);
await Promise.all([
hanyu7PinyinDic.addFile("./styles-hanyu7-pinyin.css", "styles.css"),
hanyu7ZhuyinDic.addFile("./styles-hanyu7-zhuyin.css", "styles.css"),
]);
await guifanPinyinDic.export("build");
console.log("Exported 现代汉语规范词典 拼音");
await guifanZhuyinDic.export("build");
console.log("Exported 现代汉语规范词典 注音");
await hanyu7PinyinDic.export("build");
console.log("Exported 现代汉语词典 拼音");
await hanyu7ZhuyinDic.export("build");
console.log("Exported 现代汉语词典 注音");