Skip to content

Instantly share code, notes, and snippets.

@luxuia
Created September 20, 2018 13:01
Show Gist options
  • Select an option

  • Save luxuia/3311aa2cdb35acc7dee423d72c14dcf3 to your computer and use it in GitHub Desktop.

Select an option

Save luxuia/3311aa2cdb35acc7dee423d72c14dcf3 to your computer and use it in GitHub Desktop.
local gang = require 'korea_lang'
local week = require 'gangtai_lang'
local diff_tbl = {}
function get_tbl(cfgs)
local tbl = {}
for tag, info in pairs(cfgs.entries) do
diff_tbl[tag] = {}
for tid, lang in pairs(info) do
lang.tag = tag
tbl[tid] = lang
end
end
return tbl
end
local gang_dic = get_tbl(gang)
local week_dic = get_tbl(week)
for tid, info in pairs(week_dic) do
if not gang_dic[tid] or (gang_dic[tid].CN ~= week_dic[tid].CN) then
local count = #diff_tbl[info.tag]
diff_tbl[info.tag][ count+1 ] = string.format('%s\t%s', tid, info.CN)
end
end
for tag, list in pairs(diff_tbl) do
local file = io.open(tag .. '.txt', 'w')
file:write(table.concat(list, '\n'))
file:close()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment