local export = {}
local gsub = mw.ustring.gsub
function export.affix_table(text)
return {
--noun-producing
[11] = { "-el-", "-el-", "非生產性", "動作主體和工具格 / 表示結果" },
[12] = { "-er-", "-er-", "非生產性", "表示結果" },
[13] = { "-em-", "-em-", "非生產性", "表示結果 / 多樣化" },
[21] = { "peN-", "peng-", "生產性", "施事格 / 性質 / 工具格 / 抽象 / 比較" },
[22] = { "pe-", "pe-", "非生產性", "被動 / 職業名" },
[23] = { "ke-", "ke-", "非生產性", "被動" },
[24] = { "pra-", "pra-", "非生產性", "(來自梵語)" },
[31] = { "-an", "-an", "生產性", "表示結果 / 方位格 / 集合名詞 / 多樣化 / 口語名詞 / 結果" },
[32] = { "-Man", "-man", "非生產性", "施事" },
[33] = { "-is", "-is", "非生產性", "施事" },
[34] = { "-isme", "-isme", "非生產性", "意識" },
[40] = { "ke-an", "ke- -an", "生產性", "抽象 / 方位格" },
--verb-producing
[111] = { "-el-", "-el-", "非生產性", "強烈" },
[112] = { "-em-", "-em-", "非生產性", "強烈" },
[113] = { "-er-", "-er-", "非生產性", "強烈" },
[121] = { "-", "-", "生產性", "重複" },
[131] = { "se-", "se-", "生產性", "可比性" },
[132] = { "ke-", "ke-", "非生產性", "強烈" },
[140] = { "-an", "-an", "非生產性", "重複 / 相互" },
[150] = { "ke-an", "ke- -an", "生產性", "相似 / 被動" },
[210] = { "peR-", "per-", "生產性", "使役被動" },
[221] = { "-kan", "-kan", "生產性", "使役益格" },
[222] = { "-i", "-i", "生產性", "使役(方位格)益格" },
[310] = { "meN-", "meng-", "生產性", "施事焦點" },
[320] = { "di-", "di-", "生產性", "受事焦點" },
[330] = { "teR-", "ter-", "生產性", "無施事動作" },
[340] = { "beR-", "ber-", "生產性", "表示狀態 / 習慣" },
[350] = { "mempeR-", "memper-", "生產性", "使役施事焦點" },
[360] = { "dipeR-", "diper-", "生產性", "使役受事焦點" },
--adverb-producing
[411] = { "-el-", "-el-", "非生產性", "更長的時間跨度" },
[412] = { "-em-", "-em-", "非生產性", "更長的時間跨度" },
[413] = { "-er-", "-er-", "非生產性", "更長的時間跨度" },
[420] = { "-", "-", "生產性", "重複" },
[430] = { "se-", "se-", "非生產性", "即時 / 習慣" },
[440] = { "-an", "-an", "非生產性", "時間跨度 / 情緒" },
}
end
local pattern_replacements = {
["N#([lmnrwy])"] = "%1",
["N#([bf])"] = "m%1",
["N#p"] = "m",
["N#t"] = "n",
["N#([cdjz])"] = "n%1",
["N#([gh])"] = "ng%1",
["N#kh?"] = "ng",
["N#s"] = "ny",
["R#r"] = "r",
["aM"] = "w",
}
local letter_replacements = {
["M"] = "m", ["N#"] = "ng", ["R#"] = "r"
}
function export.affixation(text, affix)
if affix == "-" then
text = text .. "-" .. text
elseif mw.ustring.match(affix, "^%-.+%-$") then
first_consonant = mw.ustring.match(text, "^[^aeiou]+")
text = first_consonant .. mw.ustring.sub(affix, 2, -2) .. mw.ustring.sub(text, mw.ustring.len(first_consonant) + 1, -1)
else
text = gsub(affix, "%-", "#" .. text)
text = gsub(text, "N([^aeiou]*)([aeiou])([^aeiou]*)$", "nge%1%2%3")
text = gsub(text, "meN#p", "mem")
for pattern, replacement in pairs(pattern_replacements) do
text = gsub(text, pattern, replacement)
end
text = gsub(text, "[MNR]#?", letter_replacements)
text = gsub(text, "#", "")
end
return text
end
function export.show(frame)
local args = frame:getParent().args
local p, derivations = {}, {}
local title = args["word"] or mw.title.getCurrentTitle().text
local lang = frame.args["lang"]
args["word"] = nil
if args[1] then
for index, item in ipairs(args) do
table.insert(p, (item ~= "") and item or nil)
end
local language = args["lang"] or "ms"
local m_links, lang = require("Module:links"), require("Module:languages").getByCode(language)
local first_affix, first_others = true, true
table.insert(derivations,
'<div class="NavFrame">\n<div class="NavHead" style="line-height:200%">詞綴及其他形式的派生詞' ..
'</div>\n<div class="NavContent" style="text-align:left; background-color:#F5F5FF; font-size:105%">\n')
for _, affix in ipairs(p) do
affix = mw.ustring.gsub(affix, "\n$", "")
local word, meaning, final_form = title, nil, nil
if mw.ustring.match(affix, ":") then
local xplet = mw.text.split(affix, ":")
if #xplet == 3 then
affix, final_form, meaning = xplet[1], xplet[2], xplet[3]
else
affix, meaning = xplet[1], xplet[2]
end
end
if mw.ustring.match(affix, "[0-9%+]") then
if first_affix then
table.insert(derivations, "規則的詞綴派生詞:")
end
local records, notes = {}, {}
for number in mw.text.gsplit(affix, "+") do
local number = tonumber(number) or number
local data = export.affix_table("")[number] or { number, nil, nil }
word = export.affixation(word, data[1])
if args["lang"] == "id" then
table.insert(records, data[2] ~= "-" and "''[[" .. data[2] .. "#印尼語|" .. data[1] .. "]]''" or "''redup''")
else
table.insert(records, data[2] ~= "-" and "''[[" .. data[2] .. "#馬來語|" .. data[1] .. "]]''" or "''redup''")
end
table.insert(notes, data[4])
end
table.insert(derivations, "* " .. m_links.full_link({lang = lang, term = final_form or word, gloss = meaning or nil}) .. " <small>[" .. table.concat(notes, " + ") .. "] (" .. table.concat(records, " + ") .. ") </small>")
first_affix = false
else
if first_others then
table.insert(derivations, "不規則詞綴派生詞、其他派生詞及複合詞:")
end
word = affix
first_others = false
table.insert(derivations, "* " .. m_links.full_link({lang = lang, term = word, gloss = meaning or nil}))
end
end
return table.concat(derivations, "\n") .. "</div></div>"
end
return ""
end
return export