Модуль:сын атооч
Көрүнүш
("Модуль:ky-сын атооч" барагынан багытталды)
Documentation for this module may be created at Модуль:сын атооч/doc
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 = args['уңгу'] or mw.title.getCurrentTitle().text
local syllables = args['муундар'] or ""
local root = args['уңгу'] or ""
local ipa = args['эфа'] or ""
local audio = args['аудио'] or ""
local image = args['сүрөт'] or ""
local caption = args['сүрөт мааниси'] or ""
-- Даражалар
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)
local atten = (args['басаңдатма'] and mw.text.trim(args['басаңдатма']) ~= "") and args['басаңдатма'] or ("анча " .. word .. " эмес")
local syll_fmt = mw.ustring.gsub(syllables, "|", "-")
local res = ""
if image and mw.text.trim(image) ~= "" then
res = res .. "[[File:" .. mw.text.trim(image) .. "|thumb|right|" .. caption .. "]]\n"
end
res = res .. "\n'''" .. make_link("сын атооч", "Сын атооч") .. "'''\n"
if syll_fmt ~= "" then res = res .. "* Муундарга бөлүнүшү: '''" .. syll_fmt .. "'''\n" end
if root ~= "" then res = res .. "* Уңгу: '''-" .. root .. "-'''\n" end
res = res .. "* Салыштырма даражасы: '''" .. comp .. "'''\n"
if superl ~= "" then res = res .. "* Күчөтмө даражасы: '''" .. superl .. "'''\n" end
res = res .. "* Басаңдатма даражасы: '''" .. atten .. "'''\n"
if ipa ~= "" or audio ~= "" then
res = res .. "* Айтылышы [[Жардам:Кыргыз тили үчүн ЭФА|ЭФА]]: "
if audio ~= "" then
res = res .. frame:preprocess('{{Ky-аудио|' .. audio .. '}}') .. " "
end
if ipa ~= "" then res = res .. "" .. ipa .. "" end
res = res .. "\n"
end
-- Автоматтык түрдө категорияларды кошуу
res = res .. "[[Категория:Кыргыз тили]]"
res = res .. "[[Категория:Кыргыз сын атоочтор]]"
return res
end
return p