Skip to content
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

add TranslationReg methods transform for instance of LuaTranslation #224

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

shewer
Copy link
Contributor

@shewer shewer commented Jan 16, 2023

增加 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

ex:
```lua
local function select_quality(tarn, quality)
function(tran, 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant