rime-ice/others/script/main.go

79 lines
1.9 KiB
Go
Raw Normal View History

2022-10-30 16:47:40 +01:00
package main
import (
"fmt"
"log"
"os"
"path/filepath"
2022-10-30 16:47:40 +01:00
"script/rime"
"strings"
)
func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
2023-09-03 14:16:17 +02:00
if len(os.Args) > 1 {
2023-09-03 14:16:17 +02:00
switch os.Args[1] {
case "s":
goto SORT
2023-09-03 14:16:17 +02:00
case "t":
rime.Temp()
return
case "tp":
rime.Pinyin(filepath.Join(rime.RimeDir, "cn_dicts/temp.txt"))
return
}
2023-06-30 19:50:01 +02:00
}
2022-10-30 16:47:40 +01:00
// Emoji 检查和更新
2023-04-13 11:04:44 +02:00
rime.CheckAndGenerateEmoji()
2022-10-30 16:47:40 +01:00
fmt.Println("--------------------------------------------------")
2023-06-08 15:53:24 +02:00
// 从 others/cn_en.txt 更新中英混输词库
rime.CnEn()
fmt.Println("--------------------------------------------------")
2023-06-29 14:44:38 +02:00
// 为没注音的词汇半自动注音
rime.Pinyin(rime.ExtPath)
fmt.Println("--------------------------------------------------")
2023-04-13 11:04:44 +02:00
// 为 ext、tencent 没权重的词条加上权重,有权重的改为下面设置的权重
2023-06-29 14:44:38 +02:00
rime.AddWeight(rime.ExtPath, 100)
rime.AddWeight(rime.TencentPath, 100)
2022-10-30 16:47:40 +01:00
fmt.Println("--------------------------------------------------")
2023-04-13 11:04:44 +02:00
// 检查
// _type: 1 只有汉字 2 汉字+注音 3 汉字+注音+权重 4 汉字+权重
rime.Check(rime.HanziPath, 3)
rime.Check(rime.BasePath, 3)
2023-06-26 09:39:10 +02:00
rime.Check(rime.ExtPath, 3)
2023-04-13 11:04:44 +02:00
rime.Check(rime.TencentPath, 4)
fmt.Println("--------------------------------------------------")
2022-10-30 16:47:40 +01:00
// 检查同义多音字
rime.CheckPolyphone(rime.BasePath)
rime.CheckPolyphone(rime.ExtPath)
fmt.Println("--------------------------------------------------")
2023-04-13 11:04:44 +02:00
areYouOK()
2022-10-30 16:47:40 +01:00
2023-06-30 19:50:01 +02:00
SORT:
2023-04-13 11:04:44 +02:00
// 排序,顺便去重
2022-10-30 16:47:40 +01:00
rime.Sort(rime.HanziPath, 3)
2023-07-23 15:36:21 +02:00
rime.Sort(filepath.Join(rime.RimeDir, "cn_dicts/41448.dict.yaml"), 2)
rime.Sort(rime.BasePath, 3)
2023-06-26 09:39:10 +02:00
rime.Sort(rime.ExtPath, 3)
2023-04-13 11:04:44 +02:00
rime.Sort(rime.TencentPath, 4)
2024-02-25 12:00:19 +01:00
rime.Sort(filepath.Join(rime.RimeDir, "en_dicts/en.dict.yaml"), 2)
2022-10-30 16:47:40 +01:00
}
2023-04-13 11:04:44 +02:00
func areYouOK() {
fmt.Println("Are you OK:")
2022-10-30 16:47:40 +01:00
var isOK string
_, _ = fmt.Scanf("%s", &isOK)
isOK = strings.ToLower(isOK)
if isOK != "ok" && isOK != "y" && isOK != "yes" {
2022-10-30 16:47:40 +01:00
os.Exit(123)
}
}