-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_xhloopfly.sh
338 lines (294 loc) · 27.5 KB
/
make_xhloopfly.sh
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
#!/bin/bash
set -e
set -x
# BUILD_TYPE="$1"
rm -rf xhloopfly-chs
rm -rf xhloopfly-cht
# 生成繁體
cp -a ./rime-moran/. ./xhloopfly-cht
rm -rf ./xhloopfly-cht/.git
rm -rf ./xhloopfly-cht/.gitignore
rm -rf ./xhloopfly-cht/README.md
rm -rf ./xhloopfly-cht/README-en.md
rm -rf ./xhloopfly-cht/.github/
perl -CSAD -i -pe 's/(^.*ZRM-SPECIFIC)/# $1/' ./xhloopfly-cht/moran.yaml
perl -0777 -i -pe 's/( user_sentence_top:)\n( __append:)\n( __patch:)/$1\n# $2\n# $3/' ./xhloopfly-cht/moran.yaml
# mv ./xhloopfly-cht/punctuation.yaml ./schema
# cp ./rime-moran/tools/data/flypydb.txt ./tools-additional
# sed -i 's/ /\t/g' ./tools-additional/flypydb.txt
# 生成簡體
cd ./xhloopfly-cht/
sed -i "s/^git archive HEAD -o archive.tar/tar -cvf archive.tar .\//g" ./make_simp_dist.sh
sed -i "s/^cp 下载与安装说明/# cp 下载与安装说明/g" ./make_simp_dist.sh
sed -i "s/^sedi 's\/MORAN_VARIANT\/简体\/'/# sedi 's\/MORAN_VARIANT\/简体\/'/g" ./make_simp_dist.sh
sed -i 's/^7z a.*/cp -a .\/dist\/. ..\/xhloopfly-chs/g' ./make_simp_dist.sh
bash -x ./make_simp_dist.sh
cd ..
# 轉換詞庫
cd ./tools-additional
# 轉換繁体詞庫
echo 轉換繁体詞庫...
sed '/\.\.\./q' ../xhloopfly-cht/moran.chars.dict.yaml > ../xhloopfly-cht/moran.chars.dict.yaml.bak
python3 gen_dict_with_shape.py -p xhloopfly -x flypydb -i ../data/zdicdbtonesorted.yaml -o ../xhloopfly-cht/temp.txt
perl -CSAD -i -pe "s/(.*);;/\1/g" ../xhloopfly-cht/temp.txt
# perl -CSAD -i -pe "s/.*\t.*;[a-z]{0,1}\n//g" ../xhloopfly-cht/temp.txt
# perl -CSAD -i -pe "s/.*\t[a-z]{2};;.*\n//g" ../xhloopfly-cht/temp.txt
echo "" >> ../xhloopfly-cht/moran.chars.dict.yaml.bak
cat ../xhloopfly-cht/temp.txt >> ../xhloopfly-cht/moran.chars.dict.yaml.bak
sed '/\.\.\./q' ../xhloopfly-cht/moran.base.dict.yaml > ../xhloopfly-cht/moran.base.dict.yaml.bak
cp ../rime-snow-pinyin/snow_pinyin.base.dict.yaml ../xhloopfly-cht/snow_pinyin.base.dict.yaml
sed -i '0,/\.\.\./d' ../xhloopfly-cht/snow_pinyin.base.dict.yaml
python3 gen_dict_with_shape.py -p xhloopfly -x flypydb -t -i ../xhloopfly-cht/snow_pinyin.base.dict.yaml -o ../xhloopfly-cht/temp.txt
# echo "" >> ../xhloopfly-cht/moran.base.dict.yaml.bak
cat ../xhloopfly-cht/temp.txt >> ../xhloopfly-cht/moran.base.dict.yaml.bak
rm ../xhloopfly-cht/snow_pinyin.base.dict.yaml
# python3 schemagen.py convert-sp --to=flypy --rime-dict=../../xhloopfly-cht/moran.tencent.dict.yaml > ../../xhloopfly-cht/moran.tencent.dict.yaml.bak
# python3 schemagen.py convert-sp --to=flypy --rime-dict=../../xhloopfly-cht/moran.moe.dict.yaml > ../../xhloopfly-cht/moran.moe.dict.yaml.bak
# python3 schemagen.py convert-sp --to=flypy --rime-dict=../../xhloopfly-cht/moran.computer.dict.yaml > ../../xhloopfly-cht/moran.computer.dict.yaml.bak
# python3 schemagen.py convert-sp --to=flypy --rime-dict=../../xhloopfly-cht/moran.hanyu.dict.yaml > ../../xhloopfly-cht/moran.hanyu.dict.yaml.bak
# python3 schemagen.py convert-sp --to=flypy --rime-dict=../../xhloopfly-cht/moran.words.dict.yaml > ../../xhloopfly-cht/moran.words.dict.yaml.bak
python3 convert_sp.py -i ../xhloopfly-cht/zrlf.dict.yaml -o ../xhloopfly-cht/zrlf.dict.yaml.bak
sed '/#----------詞庫----------#/q' ../xhloopfly-cht/moran_fixed.dict.yaml > ../xhloopfly-cht/moran_fixed.dict.yaml.bak
cp ../data/assess.tiger-code.com/xhloopfly.simpchars.txt ../xhloopfly-cht/xhloopfly.simpchars.txt && opencc -i ../xhloopfly-cht/xhloopfly.simpchars.txt -o ../xhloopfly-cht/temp.txt -c s2t
echo "" >> ../xhloopfly-cht/moran_fixed.dict.yaml.bak
cat ../xhloopfly-cht/temp.txt >> ../xhloopfly-cht/moran_fixed.dict.yaml.bak
opencc -i ../data/assess.tiger-code.com/xhloop.simpwords.txt -o ../xhloopfly-cht/temp.txt -c s2t
echo "" >> ../xhloopfly-cht/moran_fixed.dict.yaml.bak && cat ../xhloopfly-cht/temp.txt >> ../xhloopfly-cht/moran_fixed.dict.yaml.bak
perl -CSAD -i -pe "s/^[\x{4e00}-\x{9fff}\x{3007}\x{3400}-\x{4dbf}\x{20000}-\x{2a6df}\x{2a700}-\x{2b73f}\x{2b740}-\x{2b81f}\x{2b820}-\x{2ceaf}\x{2ceb0}-\x{2ebe0}\x{30000}-\x{3134a}\x{31350}-\x{323af}\x{2ebf0}-\x{2ee5f}]{1}\t[A-Za-z]+.*\n//g" ../xhloopfly-cht/moran_fixed.dict.yaml
perl -CSAD -i -pe "s/^[\x{4e00}-\x{9fff}\x{3007}\x{3400}-\x{4dbf}\x{20000}-\x{2a6df}\x{2a700}-\x{2b73f}\x{2b740}-\x{2b81f}\x{2b820}-\x{2ceaf}\x{2ceb0}-\x{2ebe0}\x{30000}-\x{3134a}\x{31350}-\x{323af}\x{2ebf0}-\x{2ee5f}]{3}\t[A-Za-z]{4}+\n//g" ../xhloopfly-cht/moran_fixed.dict.yaml
perl -CSAD -i -pe "s/^[\x{4e00}-\x{9fff}\x{3007}\x{3400}-\x{4dbf}\x{20000}-\x{2a6df}\x{2a700}-\x{2b73f}\x{2b740}-\x{2b81f}\x{2b820}-\x{2ceaf}\x{2ceb0}-\x{2ebe0}\x{30000}-\x{3134a}\x{31350}-\x{323af}\x{2ebf0}-\x{2ee5f}]{2}\t[A-Za-z]{3,4}+\n//g" ../xhloopfly-cht/moran_fixed.dict.yaml
sed '0,/#----------詞庫----------#/d' ../xhloopfly-cht/moran_fixed.dict.yaml >> ../xhloopfly-cht/moran_fixed.dict.yaml.bak
opencc -i ../data/assess.tiger-code.com/common.simp.words.txt -o ../xhloopfly-cht/temp.txt -c s2t
echo "" >> ../xhloopfly-cht/moran_fixed.dict.yaml.bak && cat ../xhloopfly-cht/temp.txt >> ../xhloopfly-cht/moran_fixed.dict.yaml.bak && perl -i -ne 'print if !$seen{$_}++' ../xhloopfly-cht/moran_fixed.dict.yaml.bak
rm ../xhloopfly-cht/xhloopfly.simpchars.txt
sed '/#----------词库----------#/q' ../xhloopfly-cht/moran_fixed_simp.dict.yaml > ../xhloopfly-cht/moran_fixed_simp.dict.yaml.bak
cp ../data/assess.tiger-code.com/xhloopfly.simpchars.txt ../xhloopfly-cht/xhloopfly.simpchars.txt && cp ../xhloopfly-cht/xhloopfly.simpchars.txt ../xhloopfly-cht/temp.txt
echo "" >> ../xhloopfly-cht/moran_fixed_simp.dict.yaml.bak
cat ../xhloopfly-cht/temp.txt >> ../xhloopfly-cht/moran_fixed_simp.dict.yaml.bak
cp ../data/assess.tiger-code.com/xhloop.simpwords.txt ../xhloopfly-cht/temp.txt
echo "" >> ../xhloopfly-cht/moran_fixed_simp.dict.yaml.bak && cat ../xhloopfly-cht/temp.txt >> ../xhloopfly-cht/moran_fixed_simp.dict.yaml.bak
perl -CSAD -i -pe "s/^[\x{4e00}-\x{9fff}\x{3007}\x{3400}-\x{4dbf}\x{20000}-\x{2a6df}\x{2a700}-\x{2b73f}\x{2b740}-\x{2b81f}\x{2b820}-\x{2ceaf}\x{2ceb0}-\x{2ebe0}\x{30000}-\x{3134a}\x{31350}-\x{323af}\x{2ebf0}-\x{2ee5f}]{1}\t[A-Za-z]+.*\n//g" ../xhloopfly-cht/moran_fixed_simp.dict.yaml
perl -CSAD -i -pe "s/^[\x{4e00}-\x{9fff}\x{3007}\x{3400}-\x{4dbf}\x{20000}-\x{2a6df}\x{2a700}-\x{2b73f}\x{2b740}-\x{2b81f}\x{2b820}-\x{2ceaf}\x{2ceb0}-\x{2ebe0}\x{30000}-\x{3134a}\x{31350}-\x{323af}\x{2ebf0}-\x{2ee5f}]{3}\t[A-Za-z]{4}+\n//g" ../xhloopfly-cht/moran_fixed_simp.dict.yaml
perl -CSAD -i -pe "s/^[\x{4e00}-\x{9fff}\x{3007}\x{3400}-\x{4dbf}\x{20000}-\x{2a6df}\x{2a700}-\x{2b73f}\x{2b740}-\x{2b81f}\x{2b820}-\x{2ceaf}\x{2ceb0}-\x{2ebe0}\x{30000}-\x{3134a}\x{31350}-\x{323af}\x{2ebf0}-\x{2ee5f}]{2}\t[A-Za-z]{3,4}+\n//g" ../xhloopfly-cht/moran_fixed_simp.dict.yaml
sed '0,/#----------词库----------#/d' ../xhloopfly-cht/moran_fixed_simp.dict.yaml >> ../xhloopfly-cht/moran_fixed_simp.dict.yaml.bak
cp ../data/assess.tiger-code.com/common.simp.words.txt ../xhloopfly-cht/temp.txt
echo "" >> ../xhloopfly-cht/moran_fixed_simp.dict.yaml.bak && cat ../xhloopfly-cht/temp.txt >> ../xhloopfly-cht/moran_fixed_simp.dict.yaml.bak && perl -i -ne 'print if !$seen{$_}++' ../xhloopfly-cht/moran_fixed_simp.dict.yaml.bak
rm ../xhloopfly-cht/xhloopfly.simpchars.txt
mv ../xhloopfly-cht/moran.chars.dict.yaml{.bak,}
mv ../xhloopfly-cht/moran.base.dict.yaml{.bak,}
# mv ../xhloopfly-cht/moran.tencent.dict.yaml{.bak,}
# mv ../xhloopfly-cht/moran.moe.dict.yaml{.bak,}
# mv ../xhloopfly-cht/moran.computer.dict.yaml{.bak,}
# mv ../xhloopfly-cht/moran.hanyu.dict.yaml{.bak,}
# mv ../xhloopfly-cht/moran.words.dict.yaml{.bak,}
mv ../xhloopfly-cht/moran_fixed.dict.yaml{.bak,}
mv ../xhloopfly-cht/moran_fixed_simp.dict.yaml{.bak,}
mv ../xhloopfly-cht/zrlf.dict.yaml{.bak,}
# 轉換简体詞庫
echo 轉換简体詞庫...
sed '/\.\.\./q' ../xhloopfly-chs/moran.chars.dict.yaml > ../xhloopfly-chs/moran.chars.dict.yaml.bak
python3 gen_dict_with_shape.py -p xhloopfly -x flypydb -i ../data/zdicdbtonesorted.yaml -o ../xhloopfly-chs/temp.txt
perl -CSAD -i -pe "s/(.*);;/\1/g" ../xhloopfly-chs/temp.txt
# perl -CSAD -i -pe "s/.*\t.*;[a-z]{0,1}\n//g" ../xhloopfly-chs/temp.txt
# perl -CSAD -i -pe "s/.*\t[a-z]{2};;.*\n//g" ../xhloopfly-chs/temp.txt
echo "" >> ../xhloopfly-chs/moran.chars.dict.yaml.bak
cat ../xhloopfly-chs/temp.txt >> ../xhloopfly-chs/moran.chars.dict.yaml.bak
sed '/\.\.\./q' ../xhloopfly-chs/moran.base.dict.yaml > ../xhloopfly-chs/moran.base.dict.yaml.bak
cp ../rime-snow-pinyin/snow_pinyin.base.dict.yaml ../xhloopfly-chs/snow_pinyin.base.dict.yaml
sed -i '0,/\.\.\./d' ../xhloopfly-chs/snow_pinyin.base.dict.yaml
python3 gen_dict_with_shape.py -p xhloopfly -x flypydb -s -i ../xhloopfly-chs/snow_pinyin.base.dict.yaml -o ../xhloopfly-chs/temp.txt
# echo "" >> ../xhloopfly-chs/moran.base.dict.yaml.bak
cat ../xhloopfly-chs/temp.txt >> ../xhloopfly-chs/moran.base.dict.yaml.bak
rm ../xhloopfly-chs/snow_pinyin.base.dict.yaml
# python3 schemagen.py convert-sp --to=flypy --rime-dict=../../xhloopfly-chs/moran.tencent.dict.yaml > ../../xhloopfly-chs/moran.tencent.dict.yaml.bak
# python3 schemagen.py convert-sp --to=flypy --rime-dict=../../xhloopfly-chs/moran.moe.dict.yaml > ../../xhloopfly-chs/moran.moe.dict.yaml.bak
# python3 schemagen.py convert-sp --to=flypy --rime-dict=../../xhloopfly-chs/moran.computer.dict.yaml > ../../xhloopfly-chs/moran.computer.dict.yaml.bak
# python3 schemagen.py convert-sp --to=flypy --rime-dict=../../xhloopfly-chs/moran.hanyu.dict.yaml > ../../xhloopfly-chs/moran.hanyu.dict.yaml.bak
# python3 schemagen.py convert-sp --to=flypy --rime-dict=../../xhloopfly-chs/moran.words.dict.yaml > ../../xhloopfly-chs/moran.words.dict.yaml.bak
python3 convert_sp.py -i ../xhloopfly-chs/zrlf.dict.yaml -o ../xhloopfly-chs/zrlf.dict.yaml.bak
sed '/#----------詞庫----------#/q' ../xhloopfly-chs/moran_fixed.dict.yaml > ../xhloopfly-chs/moran_fixed.dict.yaml.bak
cp ../data/assess.tiger-code.com/xhloopfly.simpchars.txt ../xhloopfly-chs/xhloopfly.simpchars.txt && opencc -i ../xhloopfly-chs/xhloopfly.simpchars.txt -o ../xhloopfly-chs/temp.txt -c s2t
echo "" >> ../xhloopfly-chs/moran_fixed.dict.yaml.bak
cat ../xhloopfly-chs/temp.txt >> ../xhloopfly-chs/moran_fixed.dict.yaml.bak
opencc -i ../data/assess.tiger-code.com/xhloop.simpwords.txt -o ../xhloopfly-chs/temp.txt -c s2t
echo "" >> ../xhloopfly-chs/moran_fixed.dict.yaml.bak && cat ../xhloopfly-chs/temp.txt >> ../xhloopfly-chs/moran_fixed.dict.yaml.bak
perl -CSAD -i -pe "s/^[\x{4e00}-\x{9fff}\x{3007}\x{3400}-\x{4dbf}\x{20000}-\x{2a6df}\x{2a700}-\x{2b73f}\x{2b740}-\x{2b81f}\x{2b820}-\x{2ceaf}\x{2ceb0}-\x{2ebe0}\x{30000}-\x{3134a}\x{31350}-\x{323af}\x{2ebf0}-\x{2ee5f}]{1}\t[A-Za-z]+.*\n//g" ../xhloopfly-chs/moran_fixed.dict.yaml
perl -CSAD -i -pe "s/^[\x{4e00}-\x{9fff}\x{3007}\x{3400}-\x{4dbf}\x{20000}-\x{2a6df}\x{2a700}-\x{2b73f}\x{2b740}-\x{2b81f}\x{2b820}-\x{2ceaf}\x{2ceb0}-\x{2ebe0}\x{30000}-\x{3134a}\x{31350}-\x{323af}\x{2ebf0}-\x{2ee5f}]{3}\t[A-Za-z]{4}+\n//g" ../xhloopfly-chs/moran_fixed.dict.yaml
perl -CSAD -i -pe "s/^[\x{4e00}-\x{9fff}\x{3007}\x{3400}-\x{4dbf}\x{20000}-\x{2a6df}\x{2a700}-\x{2b73f}\x{2b740}-\x{2b81f}\x{2b820}-\x{2ceaf}\x{2ceb0}-\x{2ebe0}\x{30000}-\x{3134a}\x{31350}-\x{323af}\x{2ebf0}-\x{2ee5f}]{2}\t[A-Za-z]{3,4}+\n//g" ../xhloopfly-chs/moran_fixed.dict.yaml
sed '0,/#----------詞庫----------#/d' ../xhloopfly-chs/moran_fixed.dict.yaml >> ../xhloopfly-chs/moran_fixed.dict.yaml.bak
opencc -i ../data/assess.tiger-code.com/common.simp.words.txt -o ../xhloopfly-chs/temp.txt -c s2t
echo "" >> ../xhloopfly-chs/moran_fixed.dict.yaml.bak && cat ../xhloopfly-chs/temp.txt >> ../xhloopfly-chs/moran_fixed.dict.yaml.bak && perl -i -ne 'print if !$seen{$_}++' ../xhloopfly-chs/moran_fixed.dict.yaml.bak
rm ../xhloopfly-chs/xhloopfly.simpchars.txt
sed '/#----------词库----------#/q' ../xhloopfly-chs/moran_fixed_simp.dict.yaml > ../xhloopfly-chs/moran_fixed_simp.dict.yaml.bak
cp ../data/assess.tiger-code.com/xhloopfly.simpchars.txt ../xhloopfly-chs/xhloopfly.simpchars.txt && cp ../xhloopfly-chs/xhloopfly.simpchars.txt ../xhloopfly-chs/temp.txt
echo "" >> ../xhloopfly-chs/moran_fixed_simp.dict.yaml.bak
cat ../xhloopfly-chs/temp.txt >> ../xhloopfly-chs/moran_fixed_simp.dict.yaml.bak
cp ../data/assess.tiger-code.com/xhloop.simpwords.txt ../xhloopfly-chs/temp.txt
echo "" >> ../xhloopfly-chs/moran_fixed_simp.dict.yaml.bak && cat ../xhloopfly-chs/temp.txt >> ../xhloopfly-chs/moran_fixed_simp.dict.yaml.bak
perl -CSAD -i -pe "s/^[\x{4e00}-\x{9fff}\x{3007}\x{3400}-\x{4dbf}\x{20000}-\x{2a6df}\x{2a700}-\x{2b73f}\x{2b740}-\x{2b81f}\x{2b820}-\x{2ceaf}\x{2ceb0}-\x{2ebe0}\x{30000}-\x{3134a}\x{31350}-\x{323af}\x{2ebf0}-\x{2ee5f}]{1}\t[A-Za-z]+.*\n//g" ../xhloopfly-chs/moran_fixed_simp.dict.yaml
perl -CSAD -i -pe "s/^[\x{4e00}-\x{9fff}\x{3007}\x{3400}-\x{4dbf}\x{20000}-\x{2a6df}\x{2a700}-\x{2b73f}\x{2b740}-\x{2b81f}\x{2b820}-\x{2ceaf}\x{2ceb0}-\x{2ebe0}\x{30000}-\x{3134a}\x{31350}-\x{323af}\x{2ebf0}-\x{2ee5f}]{3}\t[A-Za-z]{4}+\n//g" ../xhloopfly-chs/moran_fixed_simp.dict.yaml
perl -CSAD -i -pe "s/^[\x{4e00}-\x{9fff}\x{3007}\x{3400}-\x{4dbf}\x{20000}-\x{2a6df}\x{2a700}-\x{2b73f}\x{2b740}-\x{2b81f}\x{2b820}-\x{2ceaf}\x{2ceb0}-\x{2ebe0}\x{30000}-\x{3134a}\x{31350}-\x{323af}\x{2ebf0}-\x{2ee5f}]{2}\t[A-Za-z]{3,4}+\n//g" ../xhloopfly-chs/moran_fixed_simp.dict.yaml
sed '0,/#----------词库----------#/d' ../xhloopfly-chs/moran_fixed_simp.dict.yaml >> ../xhloopfly-chs/moran_fixed_simp.dict.yaml.bak
cp ../data/assess.tiger-code.com/common.simp.words.txt ../xhloopfly-chs/temp.txt
echo "" >> ../xhloopfly-chs/moran_fixed_simp.dict.yaml.bak && cat ../xhloopfly-chs/temp.txt >> ../xhloopfly-chs/moran_fixed_simp.dict.yaml.bak && perl -i -ne 'print if !$seen{$_}++' ../xhloopfly-chs/moran_fixed_simp.dict.yaml.bak
rm ../xhloopfly-chs/xhloopfly.simpchars.txt
mv ../xhloopfly-chs/moran.chars.dict.yaml{.bak,}
mv ../xhloopfly-chs/moran.base.dict.yaml{.bak,}
# mv ../xhloopfly-chs/moran.tencent.dict.yaml{.bak,}
# mv ../xhloopfly-chs/moran.moe.dict.yaml{.bak,}
# mv ../xhloopfly-chs/moran.computer.dict.yaml{.bak,}
# mv ../xhloopfly-chs/moran.hanyu.dict.yaml{.bak,}
# mv ../xhloopfly-chs/moran.words.dict.yaml{.bak,}
mv ../xhloopfly-chs/moran_fixed.dict.yaml{.bak,}
mv ../xhloopfly-chs/moran_fixed_simp.dict.yaml{.bak,}
mv ../xhloopfly-chs/zrlf.dict.yaml{.bak,}
cd ..
# 整理文件結構
rm -rf ./xhloopfly-cht/tools
rm -rf ./xhloopfly-cht/make_simp_dist.sh
mkdir -p ./xhloopfly-cht/snow-dicts/
mkdir -p ./xhloopfly-chs/snow-dicts/
# cp -a ./xhloopfly-cht/moran_fixed.dict.yaml ./schema/xhloopfly_fixed.dict.yaml
# cp -a ./xhloopfly-cht/moran_fixed_simp.dict.yaml ./schema/xhloopfly_fixed_simp.dict.yaml
cp -a ./schema/default.custom.xhloopfly.yaml ./xhloopfly-cht/default.custom.yaml
cp -a ./schema/default.custom.xhloopfly.yaml ./xhloopfly-chs/default.custom.yaml
# 刪去詞語簡碼
# perl -CSAD -i -pe "s/^[\x{4e00}-\x{9fa5}A-Za-z0-9\x{3007}\x{ff0c}-\x{ffee}]{2,100}\t[A-Za-z0-9]{1,3}\n//g" ./schema/moran_fixed.dict.yaml
# perl -CSAD -i -pe "s/^[\x{4e00}-\x{9fa5}A-Za-z0-9\x{3007}\x{ff0c}-\x{ffee}]{2,100}\t[A-Za-z0-9]{1,3}\t.*\n//g" ./schema/moran_fixed.dict.yaml
# perl -CSAD -i -pe "s/^[\x{4e00}-\x{9fa5}A-Za-z0-9\x{3007}\x{ff0c}-\x{ffee}]{3,100}\t[A-Za-z0-9]{4}\n//g" ./schema/moran_fixed.dict.yaml
# perl -CSAD -i -pe "s/^[\x{4e00}-\x{9fa5}A-Za-z0-9\x{3007}\x{ff01}-\x{ffee}]{3,100}\t[A-Za-z0-9]{4}\t.*\n//g" ./schema/moran_fixed.dict.yaml
# perl -CSAD -i -pe "s/^[\x{4e00}-\x{9fa5}A-Za-z0-9\x{3007}\x{ff0c}-\x{ffee}]{1,100}\t[A-Za-z0-9]{5,100}\n//g" ./schema/moran_fixed.dict.yaml
# perl -CSAD -i -pe "s/^[\x{4e00}-\x{9fa5}A-Za-z0-9\x{3007}\x{ff0c}-\x{ffee}]{1,100}\t[A-Za-z0-9]{5,100}\t.*\n//g" ./schema/moran_fixed.dict.yaml
# perl -CSAD -i -pe "s/^[\x{4e00}-\x{9fa5}A-Za-z0-9\x{3007}\x{ff0c}-\x{ffee}]{2,100}\t[A-Za-z0-9]{1,3}\n//g" ./schema/moran_fixed_simp.dict.yaml
# perl -CSAD -i -pe "s/^[\x{4e00}-\x{9fa5}A-Za-z0-9\x{3007}\x{ff0c}-\x{ffee}]{2,100}\t[A-Za-z0-9]{1,3}\t.*\n//g" ./schema/moran_fixed_simp.dict.yaml
# perl -CSAD -i -pe "s/^[\x{4e00}-\x{9fa5}A-Za-z0-9\x{3007}\x{ff0c}-\x{ffee}]{3,100}\t[A-Za-z0-9]{4}\n//g" ./schema/moran_fixed_simp.dict.yaml
# perl -CSAD -i -pe "s/^[\x{4e00}-\x{9fa5}A-Za-z0-9\x{3007}\x{ff0c}-\x{ffee}]{3,100}\t[A-Za-z0-9]{4}\t.*\n//g" ./schema/moran_fixed_simp.dict.yaml
# perl -CSAD -i -pe "s/^[\x{4e00}-\x{9fa5}A-Za-z0-9\x{3007}\x{ff0c}-\x{ffee}]{1,100}\t[A-Za-z0-9]{5,100}\n//g" ./schema/moran_fixed_simp.dict.yaml
# perl -CSAD -i -pe "s/^[\x{4e00}-\x{9fa5}A-Za-z0-9\x{3007}\x{ff0c}-\x{ffee}]{1,100}\t[A-Za-z0-9]{5,100}\t.*\n//g" ./schema/moran_fixed_simp.dict.yaml
cd ./tools-additional
# 生成繁體霧凇
python3 gen_dict_with_shape.py -p xhloopfly -x flypydb -t -i ../rime-snow-pinyin/snow_pinyin.ext.dict.yaml -o ../xhloopfly-cht/snow-dicts/xhloopfly_flypydb_ext.dict.yaml
# python3 gen_dict_with_shape.py -i ../rime-snow/cn_dicts/8105.dict.yaml -x flypydb -t -o ../xhloopfly-cht/snow-dicts/flypy_flypydb_8105.dict.yaml
# python3 gen_dict_with_shape.py -i ../rime-snow/cn_dicts/41448.dict.yaml -x flypydb -t -o ../xhloopfly-cht/snow-dicts/flypy_flypydb_41448.dict.yaml
# python3 gen_dict_with_shape.py -i ../rime-snow/cn_dicts/base.dict.yaml -x flypydb -t -o ../xhloopfly-cht/snow-dicts/flypy_flypydb_base.dict.yaml
# python3 gen_dict_with_shape.py -i ../rime-snow/cn_dicts/ext.dict.yaml -x flypydb -t -o ../xhloopfly-cht/snow-dicts/flypy_flypydb_ext.dict.yaml
# python3 gen_dict_with_shape.py -i ../rime-snow/cn_dicts/others.dict.yaml -x flypydb -t -o ../xhloopfly-cht/snow-dicts/flypy_flypydb_others.dict.yaml
python3 gen_dict_with_shape.py -p xhloopfly -x flypydb -t -i ../rime-snow-pinyin/snow_pinyin.tencent.dict.yaml -o ../xhloopfly-cht/snow-dicts/xhloopfly_flypydb_tencent.dict.yaml
# 生成簡體霧凇
python3 gen_dict_with_shape.py -p xhloopfly -x flypydb -s -i ../rime-snow-pinyin/snow_pinyin.ext.dict.yaml -o ../xhloopfly-chs/snow-dicts/xhloopfly_flypydb_ext.dict.yaml
# python3 gen_dict_with_shape.py -i ../rime-snow/cn_dicts/8105.dict.yaml -x flypydb -o ../xhloopfly-chs/snow-dicts/flypy_flypydb_8105.dict.yaml
# python3 gen_dict_with_shape.py -i ../rime-snow/cn_dicts/41448.dict.yaml -x flypydb -o ../xhloopfly-chs/snow-dicts/flypy_flypydb_41448.dict.yaml
# python3 gen_dict_with_shape.py -i ../rime-snow/cn_dicts/base.dict.yaml -x flypydb -o ../xhloopfly-chs/snow-dicts/flypy_flypydb_base.dict.yaml
# python3 gen_dict_with_shape.py -i ../rime-snow/cn_dicts/ext.dict.yaml -x flypydb -o ../xhloopfly-chs/snow-dicts/flypy_flypydb_ext.dict.yaml
# python3 gen_dict_with_shape.py -i ../rime-snow/cn_dicts/others.dict.yaml -x flypydb -o ../xhloopfly-chs/snow-dicts/flypy_flypydb_others.dict.yaml
python3 gen_dict_with_shape.py -p xhloopfly -x flypydb -s -i ../rime-snow-pinyin/snow_pinyin.tencent.dict.yaml -o ../xhloopfly-chs/snow-dicts/xhloopfly_flypydb_tencent.dict.yaml
cd ..
# 生成ocz
cp ./rime-radical-pinyin/radical.schema.yaml ./xhloopfly-chs
cp ./rime-radical-pinyin/radical.schema.yaml ./xhloopfly-cht
cp ./rime-radical-pinyin/radical_flypy.dict.yaml ./xhloopfly-cht
sed '/\.\.\./q' ./xhloopfly-cht/radical_flypy.dict.yaml > ./xhloopfly-cht/radical_flypy.dict.yaml.bak
python3 ./tools-additional/prepare_chaizi.py -i ./chaizi-re/radical.yaml -o temp.txt -c ./xhloopfly-cht/moran.chars.dict.yaml
echo "" >> ./xhloopfly-cht/radical_flypy.dict.yaml.bak
cat temp.txt >> ./xhloopfly-cht/radical_flypy.dict.yaml.bak
mv ./xhloopfly-cht/radical_flypy.dict.yaml{.bak,}
cp ./xhloopfly-cht/radical_flypy.dict.yaml ./xhloopfly-chs
rm -f temp.txt
rm -f ./xhloopfly-cht/temp.txt
rm -f ./xhloopfly-chs/temp.txt
echo xhloopfly繁體設定檔...
cd xhloopfly-cht
cp recipe.yaml recipe.yaml.bak
sed -i "s/^\( zrlf\*\)$/\1\n radical*/g" ./recipe.yaml
rm recipe.yaml.bak
cp moran.extended.dict.yaml moran.extended.dict.yaml.bak
sed -i "s/\( - moran\.words \)/ - snow-dicts\/xhloopfly_flypydb_ext # 扩展词库\n\1/g" ./moran.extended.dict.yaml
sed -i "s/\( - moran\.words \)/ - snow-dicts\/xhloopfly_flypydb_tencent # 腾讯词库\n\1/g" ./moran.extended.dict.yaml
sed -i "s/\( - moran\.tencent\)/# \1/g" ./moran.extended.dict.yaml
sed -i "s/\( - moran\.moe\)/# \1/g" ./moran.extended.dict.yaml
rm moran.extended.dict.yaml.bak
cp moran.schema.yaml xhloopfly.schema.yaml
sed -i "s/^ schema_id: moran$/ schema_id: xhloopfly/g" ./xhloopfly.schema.yaml
sed -i "s/^ name: 魔然$/ name: xhloopfly/g" ./xhloopfly.schema.yaml
sed -i "s/^\( - 方案製作:ksqsf\)$/\1\n - Integrator:jack2game/g" ./xhloopfly.schema.yaml
sed -i "s/^ 爲傳承字設計的自然碼及輔助碼智能整句輸入方案。$/ xhloopfly = moran + xhloop + flyshape + snow/g" ./xhloopfly.schema.yaml
sed -i "s/^ - moran_fixed$/ - xhloopfly_fixed/g" ./xhloopfly.schema.yaml
sed -i "s/^ - moran_sentence$/ - xhloopfly_sentence/g" ./xhloopfly.schema.yaml
sed -i "s/^\( - zrlf\)$/\1\n - radical/g" ./xhloopfly.schema.yaml
sed -i "s/^\( - reverse_lookup_translator@reverse_zrlf\)$/\1\n - reverse_lookup_translator@reverse_radical/g" ./xhloopfly.schema.yaml
sed -i "s/^\(reverse_lookup:\)$/reverse_radical:\n tag: reverse_radical\n dictionary: radical_flypy\n enable_completion: true\n prefix: \"ocz\"\n tips: 〔拆字〕\n __include: reverse_format\n\n\1/g" ./xhloopfly.schema.yaml
sed -i "s/^\( - reverse_zrlf\)$/\1\n - reverse_radical/g" ./xhloopfly.schema.yaml
sed -i "s/^\( reverse_zrlf: \"\^olf\[A-Za-z\]\*\$\"\)$/\1\n reverse_radical: \"^ocz[A-Za-z]*$\"/g" ./xhloopfly.schema.yaml
sed -i 's/\( - xform\/^o(lf\)/\1|cz/g' ./xhloopfly.schema.yaml
sed -i "s/^ enable_quick_code_hint: false$/ enable_quick_code_hint: true/g" ./xhloopfly.schema.yaml
# sed -i "s/ alphabet: abcdefghijklmnopqrstuvwxyz/ alphabet: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/g" ./xhloopfly.schema.yaml
# sed -i "s/\( - moran:\/key_bindings\/moran_capital_for_last_syllable\)/#\1/g" ./xhloopfly.schema.yaml
cp moran_aux.schema.yaml xhloopfly_aux.schema.yaml
sed -i "s/^ schema_id: moran_aux$/ schema_id: xhloopfly_aux/g" ./xhloopfly_aux.schema.yaml
sed -i "s/^ name: 魔然·輔篩$/ name: xhloopfly輔篩/g" ./xhloopfly_aux.schema.yaml
sed -i "s/^\( - 方案製作:ksqsf\)$/\1\n - Integrator:jack2game/g" ./xhloopfly_aux.schema.yaml
sed -i "s/^ 在輸入完畢雙拼碼後,可以輸入輔助碼篩選候選項,與「魔然」方案不同。$/ 在輸入完畢雙拼碼後,可以輸入輔助碼篩選候選項,與「xhloopfly」方案不同。/g" ./xhloopfly_aux.schema.yaml
# cp moran_bj.schema.yaml xhloopfly_bj.schema.yaml
# sed -i "s/^ schema_id: moran_bj$/ schema_id: xhloopfly_bj/g" ./xhloopfly_bj.schema.yaml
# sed -i "s/^ name: 魔然·並擊G$/ name: xhloopfly並擊/g" ./xhloopfly_bj.schema.yaml
# sed -i "s/^\( - 方案製作:ksqsf\)$/\1\n - Integrator:jack2game/g" ./xhloopfly_bj.schema.yaml
# sed -i "s/^ 爲傳承字設計的自然碼及輔助碼智能整句輸入方案。$/ xhloopfly = moran + xhloop + flyshape + snow/g" ./xhloopfly_bj.schema.yaml
# sed -i "s/^ - moran_fixed$/ - xhloopfly_fixed/g" ./xhloopfly_bj.schema.yaml
# sed -i "s/^ - moran_sentence$/ - xhloopfly_sentence/g" ./xhloopfly_bj.schema.yaml
cp moran_fixed.schema.yaml xhloopfly_fixed.schema.yaml
sed -i "s/^ schema_id: moran_fixed$/ schema_id: xhloopfly_fixed/g" ./xhloopfly_fixed.schema.yaml
sed -i "s/^ name: 魔然·字詞$/ name: xhloopfly字詞/g" ./xhloopfly_fixed.schema.yaml
sed -i "s/^\( - 方案製作:ksqsf\)$/\1\n - Integrator:jack2game/g" ./xhloopfly_fixed.schema.yaml
cp moran_sentence.schema.yaml xhloopfly_sentence.schema.yaml
sed -i "s/^ schema_id: moran_sentence$/ schema_id: xhloopfly_sentence/g" ./xhloopfly_sentence.schema.yaml
sed -i "s/^ name: 魔然·整句$/ name: xhloopfly整句/g" ./xhloopfly_sentence.schema.yaml
sed -i "s/^\( - 方案製作:ksqsf\)$/\1\n - Integrator:jack2game/g" ./xhloopfly_sentence.schema.yaml
cd ..
echo xhloopfly简体設定檔...
cd xhloopfly-chs
cp recipe.yaml recipe.yaml.bak
sed -i "s/^\( zrlf\*\)$/\1\n radical*/g" ./recipe.yaml
rm recipe.yaml.bak
cp moran.extended.dict.yaml moran.extended.dict.yaml.bak
sed -i "s/\( - moran\.words \)/ - snow-dicts\/xhloopfly_flypydb_ext # 扩展词库\n\1/g" ./moran.extended.dict.yaml
sed -i "s/\( - moran\.words \)/ - snow-dicts\/xhloopfly_flypydb_tencent # 腾讯词库\n\1/g" ./moran.extended.dict.yaml
sed -i "s/\( - moran\.tencent\)/# \1/g" ./moran.extended.dict.yaml
sed -i "s/\( - moran\.moe\)/# \1/g" ./moran.extended.dict.yaml
rm moran.extended.dict.yaml.bak
cp moran.schema.yaml xhloopfly.schema.yaml
sed -i "s/^ schema_id: moran$/ schema_id: xhloopfly/g" ./xhloopfly.schema.yaml
sed -i "s/^ name: 魔然$/ name: xhloopfly/g" ./xhloopfly.schema.yaml
sed -i "s/^\( - 方案製作:ksqsf\)$/\1\n - Integrator:jack2game/g" ./xhloopfly.schema.yaml
sed -i "s/^ 爲傳承字設計的自然碼及輔助碼智能整句輸入方案。$/ xhloopfly = moran + xhloop + flyshape + snow/g" ./xhloopfly.schema.yaml
sed -i "s/^ - moran_fixed$/ - xhloopfly_fixed/g" ./xhloopfly.schema.yaml
sed -i "s/^ - moran_sentence$/ - xhloopfly_sentence/g" ./xhloopfly.schema.yaml
sed -i "s/^\( - zrlf\)$/\1\n - radical/g" ./xhloopfly.schema.yaml
sed -i "s/^\( - reverse_lookup_translator@reverse_zrlf\)$/\1\n - reverse_lookup_translator@reverse_radical/g" ./xhloopfly.schema.yaml
sed -i "s/^\(reverse_lookup:\)$/reverse_radical:\n tag: reverse_radical\n dictionary: radical_flypy\n enable_completion: true\n prefix: \"ocz\"\n tips: 〔拆字〕\n __include: reverse_format\n\n\1/g" ./xhloopfly.schema.yaml
sed -i "s/^\( - reverse_zrlf\)$/\1\n - reverse_radical/g" ./xhloopfly.schema.yaml
sed -i "s/^\( reverse_zrlf: \"\^olf\[A-Za-z\]\*\$\"\)$/\1\n reverse_radical: \"^ocz[A-Za-z]*$\"/g" ./xhloopfly.schema.yaml
sed -i 's/\( - xform\/^o(lf\)/\1|cz/g' ./xhloopfly.schema.yaml
sed -i "s/^ enable_quick_code_hint: false$/ enable_quick_code_hint: true/g" ./xhloopfly.schema.yaml
# sed -i "s/ alphabet: abcdefghijklmnopqrstuvwxyz/ alphabet: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/g" ./xhloopfly.schema.yaml
# sed -i "s/\( - moran:\/key_bindings\/moran_capital_for_last_syllable\)/#\1/g" ./xhloopfly.schema.yaml
cp moran_aux.schema.yaml xhloopfly_aux.schema.yaml
sed -i "s/^ schema_id: moran_aux$/ schema_id: xhloopfly_aux/g" ./xhloopfly_aux.schema.yaml
sed -i "s/^ name: 魔然·輔篩$/ name: xhloopfly輔篩/g" ./xhloopfly_aux.schema.yaml
sed -i "s/^\( - 方案製作:ksqsf\)$/\1\n - Integrator:jack2game/g" ./xhloopfly_aux.schema.yaml
sed -i "s/^ 在輸入完畢雙拼碼後,可以輸入輔助碼篩選候選項,與「魔然」方案不同。$/ 在輸入完畢雙拼碼後,可以輸入輔助碼篩選候選項,與「xhloopfly」方案不同。/g" ./xhloopfly_aux.schema.yaml
# cp moran_bj.schema.yaml xhloopfly_bj.schema.yaml
# sed -i "s/^ schema_id: moran_bj$/ schema_id: xhloopfly_bj/g" ./xhloopfly_bj.schema.yaml
# sed -i "s/^ name: 魔然·並擊G$/ name: xhloopfly並擊/g" ./xhloopfly_bj.schema.yaml
# sed -i "s/^\( - 方案製作:ksqsf\)$/\1\n - Integrator:jack2game/g" ./xhloopfly_bj.schema.yaml
# sed -i "s/^ 爲傳承字設計的自然碼及輔助碼智能整句輸入方案。$/ xhloopfly = moran + xhloop + flyshape + snow/g" ./xhloopfly_bj.schema.yaml
# sed -i "s/^ - moran_fixed$/ - xhloopfly_fixed/g" ./xhloopfly_bj.schema.yaml
# sed -i "s/^ - moran_sentence$/ - xhloopfly_sentence/g" ./xhloopfly_bj.schema.yaml
cp moran_fixed.schema.yaml xhloopfly_fixed.schema.yaml
sed -i "s/^ schema_id: moran_fixed$/ schema_id: xhloopfly_fixed/g" ./xhloopfly_fixed.schema.yaml
sed -i "s/^ name: 魔然·字詞$/ name: xhloopfly字詞/g" ./xhloopfly_fixed.schema.yaml
sed -i "s/^\( - 方案製作:ksqsf\)$/\1\n - Integrator:jack2game/g" ./xhloopfly_fixed.schema.yaml
cp moran_sentence.schema.yaml xhloopfly_sentence.schema.yaml
sed -i "s/^ schema_id: moran_sentence$/ schema_id: xhloopfly_sentence/g" ./xhloopfly_sentence.schema.yaml
sed -i "s/^ name: 魔然·整句$/ name: xhloopfly整句/g" ./xhloopfly_sentence.schema.yaml
sed -i "s/^\( - 方案製作:ksqsf\)$/\1\n - Integrator:jack2game/g" ./xhloopfly_sentence.schema.yaml
cd ..