rime-ice/others/script/main.go
2023-07-01 01:50:01 +08:00

64 lines
1.4 KiB
Go

package main
import (
"fmt"
"log"
"os"
"script/rime"
"strings"
)
func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
if len(os.Args) > 1 && os.Args[1] == "sort" {
goto SORT
}
// 临时
rime.Temp()
// Emoji 检查和更新
rime.CheckAndGenerateEmoji()
fmt.Println("--------------------------------------------------")
// 从 others/cn_en.txt 更新中英混输词库
rime.CnEn()
fmt.Println("--------------------------------------------------")
// 为没注音的词汇半自动注音
rime.Pinyin(rime.ExtPath)
fmt.Println("--------------------------------------------------")
// 为 ext、tencent 没权重的词条加上权重,有权重的改为下面设置的权重
rime.AddWeight(rime.ExtPath, 100)
rime.AddWeight(rime.TencentPath, 100)
fmt.Println("--------------------------------------------------")
// 检查
// _type: 1 只有汉字 2 汉字+注音 3 汉字+注音+权重 4 汉字+权重
rime.Check(rime.HanziPath, 3)
rime.Check(rime.BasePath, 3)
rime.Check(rime.ExtPath, 3)
rime.Check(rime.TencentPath, 4)
fmt.Println("--------------------------------------------------")
areYouOK()
SORT:
// 排序,顺便去重
rime.Sort(rime.HanziPath, 3)
rime.Sort(rime.BasePath, 3)
rime.Sort(rime.ExtPath, 3)
rime.Sort(rime.TencentPath, 4)
}
func areYouOK() {
fmt.Println("Are you OK:")
var isOK string
_, _ = fmt.Scanf("%s", &isOK)
if strings.ToLower(isOK) != "ok" {
os.Exit(123)
}
}