Module:qya-conj
Appearance
- This module lacks a documentation subpage. Please create it.
- Useful links: subpage list • links • transclusions • testcases • sandbox
local export = {}
local PAGENAME = mw.title.getCurrentTitle().text
local tengwar = require("Module:tengwar")
function export.conjugate(frame)
-- get arguments
local args = frame:getParent().args
local stem = frame.args[1]..'␃' or PAGENAME..'␃'
stem = mw.ustring.gsub (stem, '[\-]?␃', '')
local aor = export.aorist(stem)
local pres = export.present(stem)
local past = export.past(frame.args[2])
local perf = export.past(frame.args[3])
local fut = export.future(stem)
return '<table border="1px solid #aaaaaa" style="border-collapse:collapse; background:#F9F9F9; text-align:center; width:100%" class="inflection-table">'
.. '<tr style="background:#DFDFDF"><th></th><th>Singular</th><th>Plural</th></tr>'
.. '<tr><th style="background:#DFDFDF">Aorist</th><td>'..export.show(aor[1])..'</td><td>'..export.show(aor[2])..'</td></tr>'
.. '<tr><th style="background:#DFDFDF">Present</th><td>'..export.show(pres[1])..'</td><td>'..export.show(pres[2])..'</td></tr>'
.. '<tr><th style="background:#DFDFDF">Past</th><td>'..export.show(past[1])..'</td><td>'..export.show(past[2])..'</td></tr>'
.. '<tr><th style="background:#DFDFDF">Perfect</th><td>'..export.show(perf[1])..'</td><td>'..export.show(perf[2])..'</td></tr>'
.. '<tr><th style="background:#DFDFDF">Future</th><td>'..export.show(fut[1])..'</td><td>'..export.show(fut[2])..'</td></tr>'
..'</table>'
end
function export.show(text)
return '<span style=\"font-family: \'Tengwar Annatar\', \'Tengwar Eldamar\', \'Tengwar Noldor\', \'Tengwar Parmaite\', \'Tengwar Formal\', \'Tengwar Elfica\', \'Tengwar Sindarin\', \'Tengwar Quenya\', \'Tengwar Gothika\';">'..tengwar.convert('qya', 'annatar', text)..'</span><br>'..text
end
function export.aorist(stem)
stem = stem..'␃'
stem = mw.ustring.gsub (stem, '([^au])␃', '%1ë␃')
stem = mw.ustring.gsub (stem, 'u␃', 'ë␃')
stem2 = mw.ustring.gsub (stem, '[^a]␃', 'i␃')
stem = mw.ustring.gsub (stem, '␃', '')
stem2 = mw.ustring.gsub (stem2, '␃', '')
return {stem, stem2..'r'}
end
function export.present(stem)
stem = stem..'␃'
local vow1 = {'a', 'e', 'i', 'o', 'u'}
local vow2 = {'á', 'é', 'í', 'ó', 'ú'}
for i=1, #vow1 do
stem = mw.ustring.gsub (stem, '([^aeiouäëö])'..vow1[i]..'([^aeiouäëö][au]?␃)', '%1'..vow2[i]..'%2')
end
stem = mw.ustring.gsub (stem, 'a␃', 'ë␃')
stem = mw.ustring.gsub (stem, '␃', '')
return {stem..'a', stem..'ar'}
end
function export.past(stem)
plur = mw.ustring.gsub (stem..'␃', 'ë( *[,␃])', 'e%1')
plur = mw.ustring.gsub (plur, '( *[,␃])', 'r%1')
plur = mw.ustring.gsub (plur, '␃', '')
return {stem, plur}
end
function export.future(stem)
stem = stem..'u␃'
stem = mw.ustring.gsub (stem, 'uu␃', 'ú␃')
stem = mw.ustring.gsub (stem, 'au␃', 'u␃')
stem = mw.ustring.gsub (stem, '␃', '')
return {stem..'va', stem..'var'}
end
return export