This is a private module sandbox of Dixtosa, for his own experimentation. Items in this module may be added and removed at Dixtosa's discretion; do not rely on this module's stability.
local export = {}
local lang = require("Module:languages").getByCode("oge")
local m_links = require("Module:links")
local strutils = require("Module:string utilities")
local declensionTable = require("Module:User:Dixtosa/oge-infl-noun/declension table")
--unicode charAt
function uCharAt(str, index)
return mw.ustring.sub(str, 1, 1)
end
forms = {}
rules = {}
rules = {
= {"უ"},
= {"უი", "ჳ"},
= {"უმან"},
= {"უს"},
= {"უის", "ჳს"},
= {"უისა", "ჳსა"},
= {"უით", "ჳთ"},
= {"უად"},
= {"უო"},
}
rules = {
= { "" },
= { "ჲ" },
= { "მან" },
= { "ს" },
= { "ჲს" },
= { "ჲსა" },
= { "ჲთ" },
= { "დ" },
= { "ო" },
}
rules = {
= { "" },
= { "ჲ" },
= { "მან" },
= { "ს" },
= { "ის" },
= { "ისა" },
= { "ით" },
= { "დ" },
= { "ო" },
}
rules = {
= { "" },
= { "ჲ" },
= { "მან" },
= { "ს" },
= { "ის" },
= { "ისა" },
= { "ით" },
= { "დ" },
= { "ო" },
}
rules = {
= { "" },
= { "ი" },
= { "მან" },
= { "ს" },
= { "ის" },
= { "ისა" },
= { "ით" },
= { "ად" },
= { "ო" },
}
rules = {
= { "" },
= { "ი" },
= { "მან" },
= { "ს" },
= { "ის" },
= { "ისა" },
= { "ით" },
= { "დ" },
= { "ო" },
}
ebPluralRule = {
= "",
= "ი",
= "მან",
= "ს",
= "ის",
= "ისა",
= "ით",
= "ად",
= "ო",
}
ntPluralRule = {
= "ნი",
= "თა",
= "ნო",
}
function init()
forms = {}
end
function export.getForms(args)
main(args, 1)
local combined = {}
for k, v in pairs(forms) do
combined = mw.ustring.gsub(v, "]", "")
end
for k, v in pairs(postpositions) do
combined = mw.ustring.gsub(v, "]", "")
end
return combined
end
--function export.test(args, form)
-- main(args, 1)
-- return mw.ustring.gsub(forms, "]", "")
--end
function export.show(frame)
if mw.text.split(mw.title.getCurrentTitle().prefixedText, ":") == "Template" then return "" end
local args = frame:getParent().args
main(args, 0)
return strutils.format(declensionTable.template, forms)
end
function main(args)
init()
term = args.term or mw.title.getCurrentTitle().text --'term' arg is for debug and testing purposes
local term_info = analyze(term, args.type, args)
fillTable(term_info)
override(args)
makelinks()
forms = ""
end
function analyze(term, type, parameters)
if (type == "non-syllabic-u-ending-stem") then
local stem = ""
local lastLetter = mw.ustring.sub(term, -1)
if lastLetter == "ი" then
stem = mw.ustring.sub(term, 0, -3)
end
if lastLetter == "ჳ" then
stem = mw.ustring.sub(term, 0, -2)
end
return {
rule_code = "non-syllabic-u-ending-stem",
stemSingular = {
abs = stem, nom = stem, erg = stem, dat = stem, gen = stem, dir = stem, ins = stem, adv = stem, voc = stem
},
stemPluralEb = stem .. "უ",
stemPluralNt = stem .. "უ"
}
end
if (type == "u-ending-stem") then
local stem = mw.ustring.sub(term, 0, -2)
return {
rule_code = "ou-ending-stem",
stemSingular = {
abs = stem, nom = stem, erg = stem, dat = stem, gen = stem, dir = stem, ins = stem, adv = stem, voc = stem
},
stemPluralEb = stem,
stemPluralNt = stem
}
end
if (type == "o-ending-stem") then
local stem = mw.ustring.sub(term, 0, -2)
return {
rule_code = "ou-ending-stem",
stemSingular = {
abs = stem, nom = stem, erg = stem, dat = stem, gen = stem, dir = stem, ins = stem, adv = stem, voc = stem
},
stemPluralEb = stem,
stemPluralNt = stem
}
end
if (type == "e-ending-stem") then
local stem = mw.ustring.sub(term, 0, -2)
local trimmed_stem = mw.ustring.sub(term, 0, -3)
return {
rule_code = type,
stemSingular = {
abs = stem, nom = stem, erg = stem, dat = stem, gen = trimmed_stem, dir = trimmed_stem, ins = trimmed_stem, adv = stem, voc = stem
},
stemPluralEb = trimmed_stem,
stemPluralNt = stem
}
end
if (type == "a-ending-stem") then
local stem = mw.ustring.sub(term, 0, -2)
local trimmed_stem = mw.ustring.sub(term, 0, -3)
return {
rule_code = type,
stemSingular = {
abs = stem, nom = stem, erg = stem, dat = stem, gen = trimmed_stem, dir = trimmed_stem, ins = stem, adv = stem, voc = stem
},
stemPluralEb = trimmed_stem,
stemPluralNt = stem
}
end
if (type == "consonant-ending-stem") then
local stem = mw.ustring.sub(term, 0, -2)
return {
rule_code = type,
stemSingular = {
abs = stem, nom = stem, erg = stem, dat = stem, gen = stem, dir = stem, ins = stem, adv = stem, voc = stem
},
stemPluralEb = stem,
stemPluralNt = stem
}
end
if (type == "ili-ending-stem") then
local stem = mw.ustring.sub(term, 0, -2)
local advstem = mw.ustring.sub(term, 0, -3)
return {
rule_code = type,
stemSingular = {
abs = stem, nom = stem, erg = stem, dat = stem, gen = stem, dir = stem, ins = stem, adv = advstem, voc = stem
},
stemPluralEb = stem,
stemPluralNt = stem
}
end
if (type == "reducible-stem") then
local stem = mw.ustring.sub(term, 0, -2)
local reduced_stem = parameters.reduced_stem
return {
rule_code = "consonant-ending-stem",
stemSingular = {
abs = stem, nom = stem, erg = stem, dat = stem, gen = reduced_stem, dir = reduced_stem, ins = reduced_stem, adv = reduced_stem, voc = stem
},
stemPluralEb = reduced_stem,
stemPluralNt = stem
}
end
end
function fillTable(term_info, params)
local noPlural = false;
local stemSingular = term_info.stemSingular
local stemPluralEb = term_info.stemPluralEb
local stemPluralNt = term_info.stemPluralNt
local rule = rules
forms = term
forms = " .. rule .. "]]"
if rule ~= nil then
forms = forms .. ", " .. " .. rule .. "]]"
end
forms = " .. rule .. "]]"
if rule ~= nil then
forms = forms .. ", " .. " .. rule .. "]]"
end
forms = " .. rule .. "]]"
if rule ~= nil then
forms = forms .. ", " .. " .. rule .. "]]"
end
forms = " .. rule .. "]]" .. "(ა)"
if rule ~= nil then
forms = forms .. ", " .. " .. rule .. "]]" .. "(ა)"
end
forms = " .. rule .. "]]" .. "(ა)"
if rule ~= nil then
forms = forms .. ", " .. " .. rule .. "]]" .. "(ა)"
end
forms = " .. rule .. "]]"
if rule ~= nil then
forms = forms .. ", " .. " .. rule .. "]]"
end
forms = " .. rule .. "]]" .. "(ა)"
if rule ~= nil then
forms = forms .. ", " .. " .. rule .. "]]" .. "(ა)"
end
forms = " .. rule .. "]]"
if rule ~= nil then
forms = forms .. ", " .. " .. rule .. "]]"
end
forms = "(ჵ) .. rule .. "]]"
if rule ~= nil then
forms = forms .. ", " .. "(ჵ) .. rule .. "]]"
end
forms = noPlural or " .. "]]"
forms = noPlural or " .. "]]"
forms = noPlural or " .. "]]"
forms = noPlural or " .. "]](ა)"
forms = noPlural or " .. "]](ა)"
forms = noPlural or " .. "]]"
forms = noPlural or " .. "]](ა)"
forms = noPlural or " .. "]]"
forms = noPlural or "(ჵ) .. "]]"
forms = "—"
forms = noPlural or " .. "]]"
forms = noPlural or " .. "]]"
forms = noPlural or " .. "]]"
forms = noPlural or " .. "]]"
forms = noPlural or " .. "]]"
forms = noPlural or " .. "]]"
forms = noPlural or " .. "]]"
forms = noPlural or "(ჵ) .. "]]"
end
function override(args)
for case, text in pairs(forms) do --WARNING: NOTE, etc.
forms = mw.ustring.gsub(args or "+", "+", forms)
end
end
function makelinks()
for case, text in pairs(forms) do --WARNING: NOTE, etc.
text = mw.ustring.gsub( text, "%%](%(%))", function (captured, sav) -- hyphen is 0 or more non greedy
return m_links.full_link({lang = lang, term = captured, alt = captured .. sav}) end)
text = mw.ustring.gsub( text, "(%(%))%%]", function (vocative_intensifier, captured) -- hyphen is 0 or more non greedy
return m_links.full_link({lang = lang, term = captured, alt = vocative_intensifier .. captured}) end)
forms = mw.ustring.gsub( text, "%-%]%]", function (captured)
return m_links.full_link({lang = lang, term = captured}) end)
end
end
return export