-
Notifications
You must be signed in to change notification settings - Fork 562
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
配置的 key 是 / 的时候,.custom.yaml 中如何书写路径? #676
Comments
@fxliang 太赞了 |
patch 的语法不完备,不完全支持 key 里面含有 具体到符号定义,原题有设计好的解法。分两种情况。 如果你是方案作者,方案里定义了全套符号,如题目所示,那么你可以直接修改方案中的定义,不需要用 patch。 如果是 luna_pinyin.schema.yaml 这种需要通过 patch 修改的预设方案,源文件里往往会使用成套符号配置,如 # luna_pinyin.schema.yaml
punctuator:
import_preset: default 而没有直接在 # luna_pinyin.custom.yaml
patch:
punctuator/half_shape:
'/': '/' 编译配置的过程中,以上代码展开为: # luna_pinyin.schema.yaml
__patch:
__include: luna_pinyin.custom:/patch
punctuator:
__include: default:/punctuator 进一步展开 # luna_pinyin.schema.yaml
__patch:
punctuator/half_shape:
'/': '/'
punctuator:
punctuator/half_shape:
full_shape: # 全角符号
# ...
half_shape: #半角符号
# ...
'/' : [ '、', '/', '/', '÷' ]
symbols: # 特殊符号
# ... 打上 patch 之后,即为所求。 |
fxliang 的解法看上去比较简洁呀,可以采纳不? |
暫不採納。 |
能否新增参数以确定是否执行完备转义?就像weasel里的color_format一样,默认不是rgba,但为了照顾主流习惯做了兼容 |
对呀,这样就可以兼容了,@lotem 考虑不? |
不考虑。 用 yaml 本身的列表数据结构来描述多个字符串值比自己解析一种字符串转义编码更好。 具体是什么问题必须要重新设计一套语法? |
用 ------ Processsor
function P.init(env)
env.puncts={
Component.Processor(env.engine, Schema('punct1'), '', 'punctuator'),
Component.Processor(env.engine, Schema('punct2'), '', 'punctuator'),
Component.Processor(env.engine, Schema('punct3'), '', 'punctuator'), }
end
function P.func(key, env)
local p_no= env.engine.context:get_property('puncts_sw')
local proc= env.puncts[p_no]
return proc:processor_key_event(key)
end
------ Segment
function S.init(env)
env.puncts={
Component.Segmentor(env.engine, Schema('punct1'), '', 'punct_segmentor'),
Component.Sgementor(env.engine, Schema('punct2'), '', 'punct_segmentor'),
Component.Segmentor(env.engine, Schema('punct3'), '', 'punct_segmentor'), }
end
function S.func(segments, env)
local p_no= env.engine.context:get_property('puncts_sw')
local segm= env.puncts[p_no]
return segm:proceed(segments)
end
------------ translator
function T.init(env)
env.puncts={
Component.Translator(env.engine, Schema('punct1'), '', 'punct_translator'),
Component.Translator(env.engine, Schema('punct2'), '', 'punct_translator'),
Component.Translator(env.engine, Schema('punct3'), '', 'punct_translator'), }
end
function T.func(input,seg env)
local p_no= env.engine.context:get_property('puncts_sw')
local tran= env.puncts[p_no]
local translator = tran:query(input, seg)
if translator then
for cand in tran:query(input, seg) do
yield(cand)
end
end
end
|
例如
原配置
(luna_pinyin.schema.yaml)
我想改成 "/": "/",但不想把 half_shape 下的所有内容都抄一遍,
那么我理论上应该写成:
(luna_pinyin.custom.yaml)
此处 <斜杠> 该如何表达?
我看到 config_data.cc 里都是直接 SplitPath、JoinPath 的:
并没有对 / 做转义
The text was updated successfully, but these errors were encountered: