-
Notifications
You must be signed in to change notification settings - Fork 540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在*.dict.yaml文件中添加comment列 #538
Comments
同希望增加這个功能 |
oniondelta大佬给了一个建议:(强烈感谢!)
我按照这个方法,用reverse_lookup查找的方式,改了一份Rime配置在我的github,已经可以实现用*reverse.bin查找、标识中文释义作为英文词汇的comment的需求。这个版本的处理能力和性能比我一开始改的lua插件生成table的方式明显好多了。 engine:
processors:
- lua_processor@ecdict_processor # 非ASCII模式下,使用右shift键切换中英/英文模式
- ascii_composer translators:
- punct_translator
- script_translator
- table_translator@flypy_phrases
- table_translator@wiki_zh
- table_translator@custom_phrase_completion
- table_translator@custom_phrase_no_completion
- reverse_lookup_translator
- table_translator@ecdict
filters:
- reverse_lookup_filter@ecdict_reverse_lookup # 反查英文单词/词组的中文释义,作为comment显示
- lua_filter@ecdict_filter # 控制中英混合输入或者纯英文输入,以及截断过长的comment
- simplifier
- uniquifier ecdict: # 英文单词
enable_encoder: false
encode_commit_history: false
enable_sentence: false
enable_completion: true # 是否启用英文输入联想补全
enable_user_dict: true
dictionary: ecdict
initial_quality: 1
ecdict_reverse_lookup: # 查询英文单词/词组的中文释义, 作为Comment进行提示
overwrite_comment: true
dictionary: ECDICT_reverse
comment_format:
- xform/\\n/ /
- xform/^/ /
# - xform/^(.{1,80}).*$/$1/ # 截断过长的comment,用xform截断中文comment最后一个字符可能会出现乱码, 改成用lua_filter处理 这边生成reverse.bin的时候还遇到一个问题,ecdict_reverse.dict.yaml里面的code列是中文释义,用原始ecdcit词典内容的话,会有很多条目生成不出来。我把code列里面的空白字符清理掉、“[]"换成"()"后就可以了。这个问题的原因还有待追查。 还有一个问题是现在的版本,dict.yaml文件我对全小写的单词复制了首字母大写和全大写这两种额外的格式,dict文件变得臃肿,而且全小写、首字母大写、全大写几种形态的词频没办法合并统计,这个也有待解决。 |
「⌗」是關鍵,必須原字典中的 code 和 comment 翻譯中不存在該符號
主方案中,同之前作法,只是 easy_en 自己濾鏡(反查)自己:
|
学习到了,感谢。我之前这样替换是从原始情况下能出comment和没有comment的条目对比后自己猜的规律。
词频合并是这样的。我在ECDICT.dict.yaml文件中对同一个单词额外生成了首字母大写和全大写的条目,以便输入时也能匹配到这两种情况。但是小写、首字母大写、全大写这几个条目的词频是各自独立的。我期望的结果是能合并起来统一调整。 the the 100
The The 100
THE THE 100
of of 95
Of Of 95
OF OF 95
这个方法我试了下,关键字符我用的是“::”,在生成ECDICT.reverse.bin的时候像是遇到一些问题,好久都没生成出来,也没有log信息更新。换回ECDICT.dict.yaml和ECDICT_reverse.dict.yaml分开的方案,就很快配置完成。 |
這邊實作可以成功,老 Mac 部屬近一分鐘,1百25萬條目字典(40萬翻譯詞條)。 這方法對字典 code(英漢翻譯)內容要求較高,實作修了好幾天! 能達成想要目標的方法就是好方法,作法五花八門,僅供參考! |
用opencc https://github.com/LEOYoon-Tsaw/Rime_collections/blob/master/Rime_description.md#%E4%BA%94simplifier 用rime 的字典在英文字典上有個問題就是: rime dict 是tree 結構 , 候選字排序: "短字串"優先於"長字串" ,同字長的再排序權重。 |
先感謝 shewer 大大的貢獻! 確實有"短字串"優先於"長字串" ,無法像英漢字典一樣排序的問題, 另 opencc 早前嘗試過, |
可以寄給我 字典檔嗎 shewer@gmail.com 試試看如何提前預排序, |
英文單字:code+comment(檔案太大,故上傳 GitHub 分兩個檔) 以⌗分界,前面 code ,後面 comment 英文翻譯:
|
己改善好了 載入時間 380k 1S 50k 0.1S (Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz ,ssd ) |
这个功能有点儿用处。预计在Rime 2里给他设计上。 |
是加入 字元排序字典結構還是 dict.yaml 的comment |
發覺用leveldb也不錯,可以降低載入內存用量,只是不曉得用 leveldb.iterator().seek(string) 是不是有序的把資料調出 |
|
oniondelta/Onion_Rime_Files@4d10695 这里comment太长会导致程序崩溃的现象我也遇到了,请问的原因有找到吗?是什么? win10系统 |
什么情况,还会有rime 2吗?请问哪里有相关介绍么? |
这个功能,分享自己用脚本临时过渡的思路,顺带每次部署后自动删除无效文件。
附上AutoHotkey v2的代码供参考 Rime.rebuild()
class Rime {
static dirSoft := "c:\soft\rime\weasel-0.14.3"
static dirUser := "d:\TC\hy\rime"
static fpServer := this.dirSoft . "\WeaselServer.exe"
static fpDeployer := this.dirSoft . "\WeaselDeployer.exe"
static ready(bRun:=false) {
if (bRun || !ProcessExist("WeaselServer.exe"))
run(this.fpServer)
}
static rebuild() {
this.ready()
;合并多文件的备注到 fpTip
fpTip := Rime.dirUser . "\tip_hy.dict.yaml"
FileCopy(Rime.dirUser . "\tip_hy1.dict.yaml", fpTip, true) ;本人是在`tip_hy1`的基础上再叠加其他文件的备注内容
arrFn := [
"dict\z_hy.dict.yaml",
"cmd_work.dict.yaml",
]
sTip := ""
for fn in arrFn
sTip .= getComment(format("{1}\{2}", Rime.dirUser,fn))
FileAppend(sTip, fpTip, "UTF-8")
;重新部署并等待完成
RunWait(format("{1} /deploy", this.fpDeployer))
;核实有无错误
if (FileExist(A_LocalAppdata . "\Temp\rime.weasel.*.ERROR.*")) { ;这个变量仍不是 v2 自带的,需自行调整
msgbox("有错误文件",,0x40000)
return
}
;删除无效文件
FileDelete(fpTip) ;也可以不删
; 示例:临时方案的无效文件
FileDelete(this.dirUser . "\build\english.reverse.bin")
FileDelete(this.dirUser . "\build\english.schema.yaml")
; 示例:反查方案的无效文件
FileDelete(this.dirUser . "\build\tip_*.schema.yaml")
FileDelete(this.dirUser . "\build\tip_*.prism.bin")
FileDelete(this.dirUser . "\build\tip_*.table.bin")
getComment(fp) {
sFile := fileread(fp, "utf-8")
s := RegExReplace(sFile, "s).*eeee`n", "") ;NOTE 不要的内容用 eeee 结尾
s := RegExReplace(s, "`t.*`t", A_Tab)
return s
}
}
} |
可以在*.dict.yaml文件中添加comment列吗?我想实现如下输入英文单词时带有中文提示的效果。
![image](https://user-images.githubusercontent.com/20674069/161886529-46d5e4a1-a2b5-4945-a680-cbbfc4b17792.png)
这个功能目前可以用lua插件来实现,但是词库大了之后,会有处理容量和初始化时间的问题。如果能编译成固态词典,容量和性能都会好很多。谢谢!
The text was updated successfully, but these errors were encountered: