rime-ice/others/script/main.go

70 lines
1.5 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)
if len(os.Args) > 1 {
if os.Args[1] == "sort" {
goto SORT
}
if os.Args[1] == "temp" {
rime.Pinyin(filepath.Join(rime.RimeDir, "cn_dicts/temp"))
return
}
2023-06-30 19:50:01 +02:00
}
2023-04-19 14:20:07 +02:00
// 临时
2023-04-28 17:57:40 +02:00
rime.Temp()
2023-04-19 14:20:07 +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
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)
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)
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)
if strings.ToLower(isOK) != "ok" {
os.Exit(123)
}
}