Модуль:сын атооч
Көрүнүш
Documentation for this module may be created at Модуль:сын атооч/doc
local languages = mw.loadData("Module:languages/data");
local p = {}
local function make_link(term, display)
local target = mw.ustring.lower(term)
local text = display or target
return "[[" .. target .. "|" .. text .. "]]"
end
local function get_harmony(word)
local harmony_map = {
['а']='a', ['ы']='a', ['я']='a', ['о']='o', ['у']='o', ['ё']='o',
['е']='e', ['и']='e', ['э']='e', ['ө']='ö', ['ү']='ö', ['ю']='ö'
}
for i = mw.ustring.len(word), 1, -1 do
local char = mw.ustring.sub(word, i, i)
if harmony_map[char] then return harmony_map[char] end
end
return 'a'
end
local function voice_stem(word)
local last = mw.ustring.sub(word, -1)
if last == "п" then return mw.ustring.sub(word, 1, -2) .. "б" end
if last == "к" then return mw.ustring.sub(word, 1, -2) .. "г" end
return word
end
local function get_comp(word)
local h = get_harmony(word)
local last = mw.ustring.sub(word, -1)
local is_v = mw.ustring.find("аеёиоөуүыэюя", last)
local stem = voice_stem(word)
local suffixes = {
['a'] = {v = "раак", c = "ыраак"},
['e'] = {v = "рээк", c = "ирээк"},
['o'] = {v = "раак", c = "ураак"},
['ö'] = {v = "рөөк", c = "үрөөк"}
}
local suf = is_v and suffixes[h].v or suffixes[h].c
return stem .. suf
end
function p.render_morph_info(frame)
local args = frame.args
local word = mw.title.getCurrentTitle().text
if args['сөз'] and args['сөз'] ~= "" then
word = args['сөз']
end
local syllables = args['муундар'] or ""
local root = args['уңгу'] or ""
local audio = args['аудио'] or ""
local ipa_word = (args['эфа'] and args['эфа'] ~= "") and args['эфа'] or word
local ipa_part = frame:preprocess('{{#invoke:эфа|render|' .. ipa_word .. '}}')
local comp = (args['салыштырма'] and mw.text.trim(args['салыштырма']) ~= "") and args['салыштырма'] or get_comp(word)
local superl = (args['күчөтмө'] and mw.text.trim(args['күчөтмө']) ~= "") and args['күчөтмө'] or ("эң " .. word)
-- [[ ӨЗГӨРТҮЛДҮ ]]
-- Автоматтык генерация алынып салынды. Эгер аргумент жок болсо, nil болот.
local atten = (args['басаңдатма'] and mw.text.trim(args['басаңдатма']) ~= "") and args['басаңдатма'] or nil
local syll_fmt = mw.ustring.gsub(syllables, "|", "-")
local res = '<div style="margin-bottom: 20px; font-size: 100%; line-height: 1.6; font-family: sans-serif;">'
res = res .. "\n'''" .. make_link("сын атооч", "Сын атооч") .. "'''\n"
if syll_fmt ~= "" then res = res .. "* Муундарга бөлүнүшү: '''" .. syll_fmt .. "'''\n" end
if root ~= "" then res = res .. "* Уңгу: '''-" .. root .. "-'''\n" end
if ipa_part ~= "" or audio ~= "" then
res = res .. "* " .. ipa_part
if audio ~= "" then
res = res .. " " .. frame:preprocess('{{Ky-аудио|' .. audio .. '}}')
end
res = res .. "\n"
end
res = res .. "'''[[даража|Даражалары]]''':\n"
res = res .. "* Салыштырма: '''" .. comp .. "'''\n"
if superl ~= "" then res = res .. "* Күчөтмө: '''" .. superl .. "'''\n" end
-- [[ ӨЗГӨРТҮЛДҮ ]]
-- Эгерде atten бар болсо гана (кол менен жазылса) чыгарабыз
if atten then
res = res .. "* Басаңдатма: '''" .. atten .. "'''\n"
end
res = res .. "</div>"
res = res .. "[[Категория:Кыргыз тили]] [[Категория:Кыргыз сын атоочтор]]"
return res
end
return p