librime-lua icon indicating copy to clipboard operation
librime-lua copied to clipboard

add TranslationReg methods transform for instance of LuaTranslation

Open shewer opened this issue 3 years ago • 0 comments

增加 transltion 轉換 語法糖 Translation( func, tran,...) == tran:tranform(func,...)

Translation(func1, Translation(func2,tran) ) 等同於 tran:transform(func2):transform(func1) ex:

local function select_quality(tarn, quality)
       for cand in tran:iter() do 
            if cand.quality > 1.5 then
                yield(cand)
             end
        end
 end

filter.func(inp,env,cands)  -- inp  : instance of Translation
  local tran = inp:transform( select_quality, 1.5)
  for cand in tran:iter() do 
           yield(cand)
    end
end

shewer avatar Jan 16 '23 03:01 shewer