모듈:uk-nominal
이 모듈에 대한 설명문서는 모듈:uk-nominal/설명문서에서 만들 수 있습니다
local export = {}
local lang = require("Module:languages").getByCode("uk")
local m_links = require("Module:also/link")
local m_table = require("Module:table")
local com = require("Module:uk-common")
local m_uk_translit = require("Module:uk-translit")
local m_table_tools = require("Module:table tools")
local u = mw.ustring.char
local rfind = mw.ustring.find
local rsubn = mw.ustring.gsub
local usub = mw.ustring.sub
local HYPMARKER = "⟐"
local function rsub(term, foo, bar)
local retval = rsubn(term, foo, bar)
return retval
end
local function insert_if_not_by_key(list, new_entry, keyfunc, combine_func)
local new_entry_key = keyfunc(new_entry)
for i, item in ipairs(list) do
local item_key = keyfunc(item)
if m_table.deepEquals(item_key, new_entry_key) then
if combine_func then
list[i] = combine_func(item, new_entry)
end
return false
end
end
table.insert(list, new_entry)
return true
end
function export.combine_stem_and_suffix(stem, tr, suf, rules, old)
local first = usub(suf, 1, 1)
if rules then
local conv = rules[first]
if conv then
local ending = usub(suf, 2)
if old and conv == "и" and rfind(ending, "^́?[аеєіїоуюя]") then
conv = "і"
end
suf = conv .. ending
end
end
local is_adj = rfind(suf, "<adj>")
suf = rsub(suf, "<adj>", "")
local suftr = is_adj and m_uk_translit.tr_adj(suf, "mono")
return com.concat_ukrainian_tr(stem, tr, suf, suftr, "dopair"), suf
end
function export.show_form(forms, is_lemma, accel_form, lemma_forms, remove_monosyllabic_accents_lemma_only)
local ukrainianvals = {}
local latinvals = {}
local lemmavals = {}
local lemmauk, lemmatr
if accel_form and lemma_forms and lemma_forms[1] ~= "-" then
lemma_forms = com.combine_translit_of_duplicate_forms(com.strip_notes_from_forms(lemma_forms))
for i, form in ipairs(lemma_forms) do
local uk, tr = unpack(lemma_forms[i])
uk, tr = com.remove_monosyllabic_accents(uk, tr)
lemma_forms[i] = {uk, tr}
end
lemmauk, lemmatr = com.unzip_forms(lemma_forms)
end
for _, form in ipairs(forms) do
local uk, tr = form[1], form[2]
local ukentry, uknotes = m_table_tools.separate_notes(uk)
local trentry, trnotes
if tr then
trentry, trnotes = m_table_tools.separate_notes(tr)
trnotes = rsub(trnotes, HYPMARKER, "")
end
if (is_lemma or not remove_monosyllabic_accents_lemma_only) then
ukentry, trentry = com.remove_monosyllabic_accents(ukentry, trentry)
end
local ishyp = rfind(uknotes, HYPMARKER)
if ishyp then
uknotes = rsub(uknotes, HYPMARKER, "")
end
local ukobj = {entry = ukentry, tr = {trentry or true}, ishyp = ishyp, notes = uknotes}
if not trentry then
trentry = com.translit_no_links(ukentry)
end
if not trnotes then
trnotes = com.translit_no_links(uknotes)
end
local trobj = {entry = trentry, ishyp = ishyp, notes = trnotes}
local function keyfunc(obj)
return obj.entry
end
local function combine_func_uk(obj1, obj2)
for _, tr in ipairs(obj2.tr) do
m_table.insertIfNot(obj1.tr, tr)
end
obj1.notes = obj1.notes .. obj2.notes
obj1.ishyp = obj1.ishyp or obj2.ishyp
return obj1
end
local function combine_func_tr(obj1, obj2)
obj1.notes = obj1.notes .. obj2.notes
obj1.ishyp = obj1.ishyp or obj2.ishyp
return obj1
end
if is_lemma then
insert_if_not_by_key(lemmavals, ukobj, keyfunc, combine_func_uk)
else
insert_if_not_by_key(ukrainianvals, ukobj, keyfunc, combine_func_uk)
insert_if_not_by_key(latinvals, trobj, keyfunc, combine_func_tr)
end
end
local function concatenate_uk(objs)
local is_missing = false
for i, obj in ipairs(objs) do
local accel = nil
if lemmauk then
local translit = nil
if #obj.tr == 1 and obj.tr[1] == true then
-- no translit
else
for j, tr in ipairs(obj.tr) do
if tr == true then
obj.tr[j] = com.translit_no_links(obj.entry)
end
end
translit = table.concat(obj.tr, ", ")
end
accel = {form = accel_form, translit = translit, lemma = lemmauk, lemma_translit = lemmatr}
end
if obj.entry == "-" and #forms == 1 then
objs[i] = "—"
is_missing = true
end
if obj.ishyp then
objs[i] = m_links.full_link({lang = require("Module:languages").getByCode("uk"), term = nil, alt = obj.entry, tr = "-"}, "hypothetical")
else
objs[i] = m_links.full_link({lang = require("Module:languages").getByCode("uk"), term = obj.entry, tr = "-", accel = accel})
end
objs[i] = objs[i] .. m_table_tools.superscript_notes(obj.notes)
end
return table.concat(objs, ", "), is_missing
end
local function concatenate_tr(objs)
local scriptutils = require("Module:script utilities")
for i, obj in ipairs(objs) do
local trspan = m_links.remove_links(obj.entry) .. m_table_tools.superscript_notes(obj.notes)
if obj.ishyp then
objs[i] = scriptutils.tag_text(trspan, require("Module:languages").getByCode("uk"), require("Module:scripts").getByCode("Latn"),
"hypothetical")
else
objs[i] = scriptutils.tag_translit(trspan, require("Module:languages").getByCode("uk"), "default", " style=\"color: #888;\"")
end
end
return table.concat(objs, ", ")
end
if is_lemma then
local ukrainian_span, is_missing = concatenate_uk(lemmavals)
return ukrainian_span
else
local ukrainian_span, is_missing = concatenate_uk(ukrainianvals)
if is_missing then
return ukrainian_span
end
local latin_span = concatenate_tr(latinvals)
return ukrainian_span .. "<br />" .. latin_span
end
end
local stressed_sibilant_rules = {
["я"] = "а",
["і"] = "и",
["ю"] = "у",
}
local stressed_c_rules = {
["я"] = "а",
["ю"] = "у",
}
local unstressed_sibilant_rules = {
["я"] = "а",
["і"] = "и",
["о"] = "е",
["ю"] = "у",
}
local unstressed_c_rules = {
["я"] = "а",
["о"] = "е",
["ю"] = "у",
}
local velar_rules = {
["і"] = "и",
}
export.stressed_rules = {
["ш"] = stressed_sibilant_rules,
["щ"] = stressed_sibilant_rules,
["ч"] = stressed_sibilant_rules,
["ж"] = stressed_sibilant_rules,
["ц"] = stressed_c_rules,
["к"] = velar_rules,
["г"] = velar_rules,
["х"] = velar_rules,
}
export.unstressed_rules = {
["ш"] = unstressed_sibilant_rules,
["щ"] = unstressed_sibilant_rules,
["ч"] = unstressed_sibilant_rules,
["ж"] = unstressed_sibilant_rules,
["ц"] = unstressed_c_rules,
["к"] = velar_rules,
["г"] = velar_rules,
["х"] = velar_rules,
}
export.nonsyllabic_suffixes = m_table.listToSet({"", "ь", "й"})
export.sibilant_suffixes = m_table.listToSet({"ш", "щ", "ч", "ж"})
return export