Модул:el-c-conj
Изглед
Документацијата за овој модул можете да ја создадете на Модул:el-c-conj/док
local export = {}
-- Unicode characters that might be involved for robust checks
local IOTA_WITH_TONOS = "ί" -- U+03AF
local IOTA_PLAIN = "ι" -- U+03B9
local ACUTE_ACCENT = "´" -- U+0301 (combining acute accent)
local OMICRON_WITH_TONOS = "ό" -- U+03CC
local OMICRON_PLAIN = "ο" -- U+03BF
local KAPPA = "κ" -- U+03BA
local SIGMA = "ς" -- U+03C2 (final sigma)
-- Helper function to determine base and ending more accurately
local function get_base_and_ending(str)
local lstr = mw.ustring.len(str)
local base = ""
local ending = ""
-- Prioritize checking for 4-character endings like "ικός", "άρης"
if lstr >= 4 then
local four_char_ending = mw.ustring.sub(str, lstr - 3, lstr)
if four_char_ending == "άρης" then -- Specific check for -άρης
return mw.ustring.sub(str, 1, lstr - 4), four_char_ending
end
-- Existing robust check for "ικός" pattern (e.g., φιλικός)
local char_minus_3 = mw.ustring.sub(str, lstr - 3, lstr - 3)
local char_minus_2 = mw.ustring.sub(str, lstr - 2, lstr - 2)
local char_minus_1 = mw.ustring.sub(str, lstr - 1, lstr - 1)
local char_last = mw.ustring.sub(str, lstr, lstr)
if (char_minus_3 == IOTA_WITH_TONOS or char_minus_3 == IOTA_PLAIN) and
char_minus_2 == KAPPA and
(char_minus_1 == OMICRON_WITH_TONOS or char_minus_1 == OMICRON_PLAIN) and
char_last == SIGMA then
return mw.ustring.sub(str, 1, lstr - 4), four_char_ending -- four_char_ending would be "ικός"
end
end
-- Check for 3-character endings (like participles -αντος, -οντας)
if lstr >= 3 then
local three_char_ending = mw.ustring.sub(str, lstr - 2, lstr)
if three_char_ending == "αντος" or three_char_ending == "οντας" then
return mw.ustring.sub(str, 1, lstr - 3), three_char_ending
end
end
-- Then check for 2-character endings.
if lstr >= 2 then
local two_char_ending = mw.ustring.sub(str, lstr - 1, lstr)
-- ДОДАДЕНО: 'ύς' за правилно препознавање и сечење на коренот.
if two_char_ending == "ής" or two_char_ending == "ός" or two_char_ending == "ος" or two_char_ending == "ων" or two_char_ending == "ών" or two_char_ending == "ύς" then
return mw.ustring.sub(str, 1, lstr - 2), two_char_ending
end
end
-- Fallback for 1-character ending or very short strings
if lstr > 0 then
return mw.ustring.sub(str, 1, lstr - 1), mw.ustring.sub(str, lstr, lstr)
end
return str, "" -- Empty string, empty ending for empty input
end
-- New helper function to handle the complex declension of participles ending in -ων
local function get_on_declensions(str)
local lstr = mw.ustring.len(str)
local base_part = mw.ustring.sub(str, 1, lstr - 2)
local base_no_accent = mw.ustring.gsub(base_part, "[άέήίόύώ]", { ["ά"] = "α", ["έ"] = "ε", ["ή"] = "η", ["ί"] = "ι", ["ό"] = "ο", ["ύ"] = "υ", ["ώ"] = "ω" })
-- Check if the base form is oxytone (accent on the last syllable)
local is_oxytone = (mw.ustring.find(str, "ών$") ~= nil)
-- Check for the specific irregular case πρέπων, which keeps the accent in feminine singular
local is_prepon = (str == "πρέπων")
local neuter_ending = "ον"
if is_oxytone then
neuter_ending = "όν"
end
-- Feminine singular forms (Nom, Acu, Voc) are special for πρέπων.
local fem_s_form = base_no_accent .. "ούσα" -- Default (e.g., παρούσα)
if is_prepon then
fem_s_form = base_part .. "ουσα" -- πρέπ + ουσα = πρέπουσα (Irregular case)
end
local decl = {
-- Singular
nom_s_m = str,
nom_s_f = fem_s_form,
nom_s_n = base_part .. neuter_ending,
gen_s_m = base_no_accent .. "όντος",
gen_s_f = base_no_accent .. "ούσης",
gen_s_n = base_no_accent .. "όντος",
acu_s_m = base_no_accent .. "όντα",
acu_s_f = fem_s_form, -- Use the determined feminine singular form
acu_s_n = base_part .. neuter_ending,
voc_s_m = str,
voc_s_f = fem_s_form, -- Use the determined feminine singular form
voc_s_n = base_part .. neuter_ending,
-- Plural
nom_pl_m = base_no_accent .. "όντες",
nom_pl_f = base_no_accent .. "ούσες",
nom_pl_n = base_no_accent .. "όντα",
gen_pl_m = base_no_accent .. "όντων",
gen_pl_f = base_no_accent .. "ουσών",
gen_pl_n = base_no_accent .. "όντων",
acu_pl_m = base_no_accent .. "όντες",
acu_pl_f = base_no_accent .. "ούσες",
acu_pl_n = base_no_accent .. "όντα",
voc_pl_m = base_no_accent .. "όντες",
voc_pl_f = base_no_accent .. "ούσες",
voc_pl_n = base_no_accent .. "όντα",
}
return decl
end
-- Function to handle the specific -ύς declension (e.g. μακρύς)
local function get_ys_declensions(base, case_name)
local decl = {
-- Singular
nom_s_m = base .. "ύς", nom_s_f = base .. "ιά", nom_s_n = base .. "ύ",
gen_s_m = base .. "ιού", gen_s_f = base .. "ιάς", gen_s_n = base .. "ιού",
acu_s_m = base .. "ύ", acu_s_f = base .. "ιά", acu_s_n = base .. "ύ",
voc_s_m = base .. "ύ", voc_s_f = base .. "ιά", voc_s_n = base .. "ύ",
-- Plural
nom_pl_m = base .. "ιοί", nom_pl_f = base .. "ιές", nom_pl_n = base .. "ιά",
gen_pl_m = base .. "ιών", gen_pl_f = base .. "ιών", gen_pl_n = base .. "ιών",
acu_pl_m = base .. "ιούς", acu_pl_f = base .. "ιές", acu_pl_n = base .. "ιά",
voc_pl_m = base .. "ιοί", voc_pl_f = base .. "ιές", voc_pl_n = base .. "ιά",
}
if case_name == "Nom" then return decl.nom_s_m, decl.nom_s_f, decl.nom_s_n, decl.nom_pl_m, decl.nom_pl_f, decl.nom_pl_n
elseif case_name == "Gen" then return decl.gen_s_m, decl.gen_s_f, decl.gen_s_n, decl.gen_pl_m, decl.gen_pl_f, decl.gen_pl_n
elseif case_name == "Acu" then return decl.acu_s_m, decl.acu_s_f, decl.acu_s_n, decl.acu_pl_m, decl.acu_pl_f, decl.acu_pl_n
elseif case_name == "Voc" then return decl.voc_s_m, decl.voc_s_f, decl.voc_s_n, decl.voc_pl_m, decl.voc_pl_f, decl.voc_pl_n
end
end
function export.Nominativ_case (frame)
local args = frame:getParent().args
local str = mw.text.trim(args[1] or "")
local svr = mw.text.trim(args[2] or "")
local base, ending = get_base_and_ending(str)
local ne1, ne2, ne3, nm1, nm2, nm3 = "", "", "", "", "", ""
local ikos_comp = "ικός"
local os_comp = "ός"
local is_comp = "ής"
local ares_comp = "άρης"
local on_comp = "ων"
local on_acc_comp = "ών"
local ys_comp = "ύς" -- New check
if ending == ikos_comp then
ne1 = "[[" .. base .. "ικός]]"
ne2 = "[[" .. base .. "ική]]"
ne3 = "[[" .. base .. "ικό]]"
nm1 = "[[" .. base .. "ικοί]]"
nm2 = "[[" .. base .. "ικές]]"
nm3 = "[[" .. base .. "ικά]]"
elseif ending == ys_comp then
ne1, ne2, ne3, nm1, nm2, nm3 = get_ys_declensions(base, "Nom")
ne1 = "[[" .. ne1 .. "]]"
ne2 = "[[" .. ne2 .. "]]"
ne3 = "[[" .. ne3 .. "]]"
nm1 = "[[" .. nm1 .. "]]"
nm2 = "[[" .. nm2 .. "]]"
nm3 = "[[" .. nm3 .. "]]"
elseif ending == os_comp then
ne1 = "[[" .. base .. "ός]]"
if svr == "α" then
ne2 = "[[" .. base .. "ά]]"
else
ne2 = "[[" .. base .. "ή]]"
end
ne3 = "[[" .. base .. "ό]]"
nm1 = "[[" .. base .. "οί]]"
nm2 = "[[" .. base .. "ές]]"
nm3 = "[[" .. base .. "ά]]"
elseif ending == "ος" then
ne1 = "[[" .. base .. "ος]]"
if svr == "α" then
ne2 = "[[" .. base .. "α]]"
else
ne2 = "[[" .. base .. "η]]"
end
ne3 = "[[" .. base .. "ο]]"
nm1 = "[[" .. base .. "οι]]"
nm2 = "[[" .. base .. "ες]]"
nm3 = "[[" .. base .. "α]]"
elseif ending == on_comp or ending == on_acc_comp then
local declensions = get_on_declensions(str)
ne1 = "[[" .. declensions.nom_s_m .. "]]"
ne2 = "[[" .. declensions.nom_s_f .. "]]"
ne3 = "[[" .. declensions.nom_s_n .. "]]"
nm1 = "[[" .. declensions.nom_pl_m .. "]]"
nm2 = "[[" .. declensions.nom_pl_f .. "]]"
nm3 = "[[" .. declensions.nom_pl_n .. "]]"
elseif ending == is_comp then
local base_is = mw.ustring.sub(str, 1, mw.ustring.len(str) - 2)
ne1 = "[[" .. base_is .. "ής]]"
ne2 = "[[" .. base_is .. "ής]]"
ne3 = "[[" .. base_is .. "ές]]"
nm1 = "[[" .. base_is .. "είς]]"
nm2 = "[[" .. base_is .. "είς]]"
nm3 = "[[" .. base_is .. "ή]]"
elseif ending == ares_comp then
local stem_ares = base
ne1 = "[[" .. stem_ares .. "άρης]]"
ne2 = "[[" .. stem_ares .. "άρα]]"
ne3 = "[[" .. stem_ares .. "άρικο]]"
nm1 = "[[" .. stem_ares .. "άρηδες]]"
nm2 = "[[" .. stem_ares .. "άρες]]"
nm3 = "[[" .. stem_ares .. "άρικα]]"
else
ne1 = "[[" .. str .. "]]"
if svr == "α" then
ne2 = "[[" .. base .. "α]]"
else
ne2 = "[[" .. base .. "η]]"
end
ne3 = "[[" .. base .. "ο]]"
nm1 = "[[" .. base .. "οι]]"
nm2 = "[[" .. base .. "ες]]"
nm3 = "[[" .. base .. "α]]"
end
return "|-\n |'''Номинатив''' ||" .. ne1 .. "||" .. ne2 .. "||" .. ne3 .. "||" .. nm1 .. "||" .. nm2 .. "||" .. nm3
end
function export.Genitiv_case (frame)
local args = frame:getParent().args
local str = mw.text.trim(args[1] or "")
local svr = mw.text.trim(args[2] or "")
local base, ending = get_base_and_ending(str)
local ne1, ne2, ne3, nm1, nm2, nm3 = "", "", "", "", "", ""
local ikos_comp = "ικός"
local os_comp = "ός"
local is_comp = "ής"
local ares_comp = "άρης"
local on_comp = "ων"
local on_acc_comp = "ών"
local ys_comp = "ύς" -- New check
if ending == ikos_comp then
ne1 = "[[" .. base .. "ικού]]"
ne2 = "[[" .. base .. "ικής]]"
ne3 = "[[" .. base .. "ικού]]"
nm1 = "[[" .. base .. "ικών]]"
nm2 = "[[" .. base .. "ικών]]"
nm3 = "[[" .. base .. "ικών]]"
elseif ending == ys_comp then
ne1, ne2, ne3, nm1, nm2, nm3 = get_ys_declensions(base, "Gen")
ne1 = "[[" .. ne1 .. "]]"
ne2 = "[[" .. ne2 .. "]]"
ne3 = "[[" .. ne3 .. "]]"
nm1 = "[[" .. nm1 .. "]]"
nm2 = "[[" .. nm2 .. "]]"
nm3 = "[[" .. nm3 .. "]]"
elseif ending == os_comp then
ne1 = "[[" .. base .. "ού]]"
if svr == "α" then
ne2 = "[[" .. base .. "άς]]"
else
ne2 = "[[" .. base .. "ής]]"
end
ne3 = "[[" .. base .. "ού]]"
nm1 = "[[" .. base .. "ών]]"
nm2 = "[[" .. base .. "ών]]"
nm3 = "[[" .. base .. "ών]]"
elseif ending == "ος" then
ne1 = "[[" .. base .. "ου]]"
if svr == "α" then
ne2 = "[[" .. base .. "ας]]"
else
ne2 = "[[" .. base .. "ης]]"
end
ne3 = "[[" .. base .. "ου]]"
nm1 = "[[" .. base .. "ων]]"
nm2 = "[[" .. base .. "ων]]"
nm3 = "[[" .. base .. "ων]]"
elseif ending == on_comp or ending == on_acc_comp then
local declensions = get_on_declensions(str)
ne1 = "[[" .. declensions.gen_s_m .. "]]"
ne2 = "[[" .. declensions.gen_s_f .. "]]"
ne3 = "[[" .. declensions.gen_s_n .. "]]"
nm1 = "[[" .. declensions.gen_pl_m .. "]]"
nm2 = "[[" .. declensions.gen_pl_f .. "]]"
nm3 = "[[" .. declensions.gen_pl_n .. "]]"
elseif ending == is_comp then
local base_is = mw.ustring.sub(str, 1, mw.ustring.len(str) - 2)
ne1 = "[[" .. base_is .. "ούς]]"
ne2 = "[[" .. base_is .. "ούς]]"
ne3 = "[[" .. base_is .. "ούς]]"
nm1 = "[[" .. base_is .. "ών]]"
nm2 = "[[" .. base_is .. "ών]]"
nm3 = "[[" .. base_is .. "ών]]"
elseif ending == ares_comp then
local stem_ares = base
ne1 = "[[" .. stem_ares .. "άρη]]"
ne2 = "[[" .. stem_ares .. "άρας]]"
ne3 = "[[" .. stem_ares .. "άρικου]]"
nm1 = "[[" .. stem_ares .. "άρηδων]]"
nm2 = "[[" .. stem_ares .. "άρων]]"
nm3 = "[[" .. stem_ares .. "άρικων]]"
else
ne1 = "[[" .. base .. "ου]]"
if svr == "α" then
ne2 = "[[" .. base .. "ας]]"
else
ne2 = "[[" .. base .. "ης]]"
end
ne3 = "[[" .. base .. "ου]]"
nm1 = "[[" .. base .. "ων]]"
nm2 = "[[" .. base .. "ων]]"
nm3 = "[[" .. base .. "ων]]"
end
return "|-\n |'''Генитив''' ||" .. ne1 .. "||" .. ne2 .. "||" .. ne3 .. "||" .. nm1 .. "||" .. nm2 .. "||" .. nm3
end
function export.Acusativ_case (frame)
local args = frame:getParent().args
local str = mw.text.trim(args[1] or "")
local svr = mw.text.trim(args[2] or "")
local base, ending = get_base_and_ending(str)
local ne1, ne2, ne3, nm1, nm2, nm3 = "", "", "", "", "", ""
local ikos_comp = "ικός"
local os_comp = "ός"
local is_comp = "ής"
local ares_comp = "άρης"
local on_comp = "ων"
local on_acc_comp = "ών"
local ys_comp = "ύς" -- New check
if ending == ikos_comp then
ne1 = "[[" .. base .. "ικό]]"
ne2 = "[[" .. base .. "ική]]"
ne3 = "[[" .. base .. "ικό]]"
nm1 = "[[" .. base .. "ικούς]]"
nm2 = "[[" .. base .. "ικές]]"
nm3 = "[[" .. base .. "ικά]]"
elseif ending == ys_comp then
ne1, ne2, ne3, nm1, nm2, nm3 = get_ys_declensions(base, "Acu")
ne1 = "[[" .. ne1 .. "]]"
ne2 = "[[" .. ne2 .. "]]"
ne3 = "[[" .. ne3 .. "]]"
nm1 = "[[" .. nm1 .. "]]"
nm2 = "[[" .. nm2 .. "]]"
nm3 = "[[" .. nm3 .. "]]"
elseif ending == os_comp then
ne1 = "[[" .. base .. "ό]]"
if svr == "α" then
ne2 = "[[" .. base .. "ά]]"
else
ne2 = "[[" .. base .. "ή]]"
end
ne3 = "[[" .. base .. "ό]]"
nm1 = "[[" .. base .. "ούς]]"
nm2 = "[[" .. base .. "ές]]"
nm3 = "[[" .. base .. "ά]]"
elseif ending == "ος" then
ne1 = "[[" .. base .. "ο]]"
if svr == "α" then
ne2 = "[[" .. base .. "α]]"
else
ne2 = "[[" .. base .. "η]]"
end
ne3 = "[[" .. base .. "ο]]"
nm1 = "[[" .. base .. "ους]]"
nm2 = "[[" .. base .. "ες]]"
nm3 = "[[" .. base .. "α]]"
elseif ending == on_comp or ending == on_acc_comp then
local declensions = get_on_declensions(str)
ne1 = "[[" .. declensions.acu_s_m .. "]]"
ne2 = "[[" .. declensions.acu_s_f .. "]]"
ne3 = "[[" .. declensions.acu_s_n .. "]]"
nm1 = "[[" .. declensions.acu_pl_m .. "]]"
nm2 = "[[" .. declensions.acu_pl_f .. "]]"
nm3 = "[[" .. declensions.acu_pl_n .. "]]"
elseif ending == is_comp then
local base_is = mw.ustring.sub(str, 1, mw.ustring.len(str) - 2)
ne1 = "[[" .. base_is .. "ή]]"
ne2 = "[[" .. base_is .. "ή]]"
ne3 = "[[" .. base_is .. "ές]]"
nm1 = "[[" .. base_is .. "είς]]"
nm2 = "[[" .. base_is .. "είς]]"
nm3 = "[[" .. base_is .. "ή]]"
elseif ending == ares_comp then
local stem_ares = base
ne1 = "[[" .. stem_ares .. "άρη]]"
ne2 = "[[" .. stem_ares .. "άρα]]"
ne3 = "[[" .. stem_ares .. "άρικο]]"
nm1 = "[[" .. stem_ares .. "άρηδων]]"
nm2 = "[[" .. stem_ares .. "άρες]]"
nm3 = "[[" .. stem_ares .. "άρικα]]"
else
ne1 = "[[" .. base .. "ο]]"
if svr == "α" then
ne2 = "[[" .. base .. "α]]"
else
ne2 = "[[" .. base .. "η]]"
end
ne3 = "[[" .. base .. "ο]]"
nm1 = "[[" .. base .. "ους]]"
nm2 = "[[" .. base .. "ες]]"
nm3 = "[[" .. base .. "α]]"
end
return "|-\n |'''Акузатив''' ||" .. ne1 .. "||" .. ne2 .. "||" .. ne3 .. "||" .. nm1 .. "||" .. nm2 .. "||" .. nm3
end
function export.Vocativ_case (frame)
local args = frame:getParent().args
local str = mw.text.trim(args[1] or "")
local svr = mw.text.trim(args[2] or "")
local base, ending = get_base_and_ending(str)
local ne1, ne2, ne3, nm1, nm2, nm3 = "", "", "", "", "", ""
local ikos_comp = "ικός"
local os_comp = "ός"
local is_comp = "ής"
local ares_comp = "άρης"
local on_comp = "ων"
local on_acc_comp = "ών"
local ys_comp = "ύς" -- New check
if ending == ikos_comp then
ne1 = "[[" .. base .. "ικέ]]"
ne2 = "[[" .. base .. "ική]]"
ne3 = "[[" .. base .. "ικό]]"
nm1 = "[[" .. base .. "ικοί]]"
nm2 = "[[" .. base .. "ικές]]"
nm3 = "[[" .. base .. "ικά]]"
elseif ending == ys_comp then
ne1, ne2, ne3, nm1, nm2, nm3 = get_ys_declensions(base, "Voc")
ne1 = "[[" .. ne1 .. "]]"
ne2 = "[[" .. ne2 .. "]]"
ne3 = "[[" .. ne3 .. "]]"
nm1 = "[[" .. nm1 .. "]]"
nm2 = "[[" .. nm2 .. "]]"
nm3 = "[[" .. nm3 .. "]]"
elseif ending == os_comp then
ne1 = "[[" .. base .. "έ]]"
if svr == "α" then
ne2 = "[[" .. base .. "ά]]"
else
ne2 = "[[" .. base .. "ή]]"
end
ne3 = "[[" .. base .. "ό]]"
nm1 = "[[" .. base .. "οί]]"
nm2 = "[[" .. base .. "ές]]"
nm3 = "[[" .. base .. "ά]]"
elseif ending == "ος" then
ne1 = "[[" .. base .. "ε]]"
if svr == "α" then
ne2 = "[[" .. base .. "α]]"
else
ne2 = "[[" .. base .. "η]]"
end
ne3 = "[[" .. base .. "ο]]"
nm1 = "[[" .. base .. "οι]]"
nm2 = "[[" .. base .. "ες]]"
nm3 = "[[" .. base .. "α]]"
elseif ending == on_comp or ending == on_acc_comp then
local declensions = get_on_declensions(str)
ne1 = "[[" .. declensions.voc_s_m .. "]]"
ne2 = "[[" .. declensions.voc_s_f .. "]]"
ne3 = "[[" .. declensions.voc_s_n .. "]]"
nm1 = "[[" .. declensions.voc_pl_m .. "]]"
nm2 = "[[" .. declensions.voc_pl_f .. "]]"
nm3 = "[[" .. declensions.voc_pl_n .. "]]"
elseif ending == is_comp then
local base_is = mw.ustring.sub(str, 1, mw.ustring.len(str) - 2)
ne1 = "[[" .. base_is .. "ή]]"
ne2 = "[[" .. base_is .. "ή]]"
ne3 = "[[" .. base_is .. "ές]]"
nm1 = "[[" .. base_is .. "είς]]"
nm2 = "[[" .. base_is .. "είς]]"
nm3 = "[[" .. base_is .. "ή]]"
elseif ending == ares_comp then
local stem_ares = base
ne1 = "[[" .. stem_ares .. "άρη]]"
ne2 = "[[" .. stem_ares .. "άρα]]"
ne3 = "[[" .. stem_ares .. "άρικο]]"
nm1 = "[[" .. stem_ares .. "άρηδων]]"
nm2 = "[[" .. stem_ares .. "άρες]]"
nm3 = "[[" .. stem_ares .. "άρικα]]"
else
ne1 = "[[" .. base .. "ε]]"
if svr == "α" then
ne2 = "[[" .. base .. "α]]"
else
ne2 = "[[" .. base .. "η]]"
end
ne3 = "[[" .. base .. "ο]]"
nm1 = "[[" .. base .. "οι]]"
nm2 = "[[" .. base .. "ες]]"
nm3 = "[[" .. base .. "α]]"
end
return "|-\n |'''Вокатив''' ||" .. ne1 .. "||" .. ne2 .. "||" .. ne3 .. "||" .. nm1 .. "||" .. nm2 .. "||" .. nm3
end
return export