Module:fax-verb
Appearance
- The following documentation is located at Module:fax-verb/documentation. [edit] Categories were auto-generated by Module:module categorization. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module implements {{fax-conj}}
.
local lang = require("Module:languages").getByCode("fax")
local m_utilities = require("Module:utilities")
local m_links = require("Module:links")
local m_data = require("Module:fax-verb/data")
local match = mw.ustring.match
local gmatch = mw.ustring.gmatch
local gsub = mw.ustring.gsub
local PAGENAME = mw.title.getCurrentTitle().text
local export = {}
-- Dialects. Arbitrary order (alphabetical)
local d = {["L"] = 1, ["M"] = 2, ["V"] = 3}
local d_full = {["L"] = "Lagarteiru", ["M"] = "Mañegu", ["V"] = "Valverdeñu"}
-- Inflection functions
function export.show(frame)
local parent_args = frame:getParent().args
local dialects = parent_args[1] or nil
local base = parent_args[2] or PAGENAME
--find the ending of the verb
local infl_type = ""
if base:match("[aei]lsi$") then
infl_type = base:match("[aei]lsi$")
elseif base:match("[aei]l$") then
infl_type = base:match("[aei]l$")
else
if not m_data[base] then error("This word doesn't have a valid ending.") end
end
local data = {forms = {}, categories = {}}
data.head = base
data.infl_type = infl_type
data.prefix = parent_args.prefix or ""
-- Generate the forms
if m_data[base] then
m_data[base](parent_args, data)
else
args = require("Module:parameters").process(parent_args, m_data[infl_type].params, true)
m_data[infl_type](args, data)
end
data.info = m_links.full_link({lang = lang, alt = data.prefix .. data.head}, "term")
--generate the table and add categories
if not dialects then
error("Please provide the dialects in which this verb is used.")
elseif not dialects:match("^L?M?V?$") then
error("Please provide the dialects in which this verb is used in the proper format.")
else
local tables = ""
for dialect in gmatch(dialects, "%u") do
data.dialect = dialect
tables = tables .. make_table(data)
end
return tables .. (not parent_args.nocat and m_utilities.format_categories(data.categories, lang) or "")
end
end
-- Make the table
function make_table(data)
function export.accel_dialect()
return data.dialect
end
local function repl(param)
if param == "info" then
return mw.getContentLanguage():ucfirst(data.info or "")
elseif param == "dialect" then
return mw.getContentLanguage():ucfirst(d_full[data.dialect] or "")
elseif param == "alternation" then
return mw.getContentLanguage():ucfirst(data.alternation or "")
end
local np = data.forms[param]
local forms = np and (np["LMV"] and np[1] or np[d[data.dialect]]) or nil
if not forms then
return "—"
end
local function make_accel(key, partmsg)
local accel_form, pos, lemma = {}, "verb", PAGENAME
key = key:gsub("impfsi", "impf")
if key == "infinitive" or key == "gerund" then
accel_form = {key:sub(1,3)}
elseif key == "partmsg" then
accel_form = {"past", "part"}
pos = "past participle"
elseif key:sub(1,4) == "part" then
accel_form = {key:sub(5,5), key:sub(6,7)}
pos = "past participle"
lemma = partmsg or "test"
elseif key:match("impr") then
accel_form = {key:sub(5,5), key:sub(6,7), key:sub(1,4)}
else
accel_form = {key:sub(8,8), key:sub(9,10), key:sub(1,4), key:sub(5,7)}
end
return {form = table.concat(accel_form, "|"), pos = pos, lemma = lemma}
end
local ret, partmsg = {}, ""
for _, subform in ipairs(forms) do
if param == "partmsg" then partmsg = data.prefix .. subform end
table.insert(ret, m_links.full_link({lang = lang, term = data.prefix .. subform, accel = make_accel(param, partmsg)}))
end
return table.concat(ret, "<br/>")
end
local wikicode = [=[
<div class="NavFrame">
<div class="NavHead">Conjugation of {{{info}}} ({{{dialect}}}{{{alternation}}})</div>
<div class="NavContent">
{| class="roa-inflection-table" data-toggle-category="inflection"
|-
! colspan="3" class="roa-nonfinite-header" | infinitive
| colspan="5" align="center" | {{{infinitive}}}
|-
! colspan="3" class="roa-nonfinite-header" | gerund
| colspan="5" align="center" | {{{gerund}}}
|-
! colspan="2" rowspan="3" class="roa-nonfinite-header" | past participle
| colspan="2" class="roa-nonfinite-header" |
! colspan="2" class="roa-nonfinite-header" | masculine
! colspan="2" class="roa-nonfinite-header" | feminine
|-
! colspan="2" class="roa-nonfinite-header" | singular
| colspan="2" align="center" | {{{partmsg}}}
| colspan="2" align="center" | {{{partfsg}}}
|-
! colspan="2" class="roa-nonfinite-header" | plural
| colspan="2" align="center" | {{{partmpl}}}
| colspan="2" align="center" | {{{partfpl}}}
|-
! colspan="2" rowspan= "2" class="roa-person-number-header" |
! colspan="3" class="roa-person-number-header" | singular
! colspan="3" class="roa-person-number-header" | plural
|-
! class="roa-person-number-header" | 1st person
! class="roa-person-number-header" | 2nd person
! class="roa-person-number-header" | 3rd person
! class="roa-person-number-header" | 1st person
! class="roa-person-number-header" | 2nd person
! class="roa-person-number-header" | 3rd person
|-
! rowspan="6" class="roa-indicative-left-rail" | indicative
! class="roa-indicative-left-rail" style="width:12.5%;" |
! class="roa-indicative-left-rail" style="width:12.5%;" | ei
! class="roa-indicative-left-rail" style="width:12.5%;" | tú
! class="roa-indicative-left-rail" style="width:12.5%;" | el/ela
! class="roa-indicative-left-rail" style="width:12.5%;" | nos
! class="roa-indicative-left-rail" style="width:12.5%;" | vos
! class="roa-indicative-left-rail" style="width:12.5%;" | elis/elas
|-
! class="roa-indicative-left-rail" style="height:3em;" | present
|{{{presind1sg}}}
|{{{presind2sg}}}
|{{{presind3sg}}}
|{{{presind1pl}}}
|{{{presind2pl}}}
|{{{presind3pl}}}
|-
! class="roa-indicative-left-rail" style="height:3em;" | imperfect
|{{{impfind1sg}}}
|{{{impfind2sg}}}
|{{{impfind3sg}}}
|{{{impfind1pl}}}
|{{{impfind2pl}}}
|{{{impfind3pl}}}
|-
! class="roa-indicative-left-rail" style="height:3em;" | preterite
|{{{pretind1sg}}}
|{{{pretind2sg}}}
|{{{pretind3sg}}}
|{{{pretind1pl}}}
|{{{pretind2pl}}}
|{{{pretind3pl}}}
|-
! class="roa-indicative-left-rail" style="height:3em;" | future
|{{{futrind1sg}}}
|{{{futrind2sg}}}
|{{{futrind3sg}}}
|{{{futrind1pl}}}
|{{{futrind2pl}}}
|{{{futrind3pl}}}
|-
! class="roa-indicative-left-rail" style="height:3em;" | conditional
|{{{condind1sg}}}
|{{{condind2sg}}}
|{{{condind3sg}}}
|{{{condind1pl}}}
|{{{condind2pl}}}
|{{{condind3pl}}}
|-
! class="roa-person-number-header" style="height:.75em" colspan="8" |
|-
! class="roa-subjunctive-left-rail" rowspan="4" | subjunctive
! class="roa-subjunctive-left-rail" style="width:12.5%;" |
! class="roa-subjunctive-left-rail" style="width:12.5%;" | ei
! class="roa-subjunctive-left-rail" style="width:12.5%;" | tú
! class="roa-subjunctive-left-rail" style="width:12.5%;" | el/ela
! class="roa-subjunctive-left-rail" style="width:12.5%;" | nos
! class="roa-subjunctive-left-rail" style="width:12.5%;" | vos
! class="roa-subjunctive-left-rail" style="width:12.5%;" | elis/elas
|-
! class="roa-subjunctive-left-rail" style="height:3em;" | present
|{{{pressub1sg}}}
|{{{pressub2sg}}}
|{{{pressub3sg}}}
|{{{pressub1pl}}}
|{{{pressub2pl}}}
|{{{pressub3pl}}}
|-
! class="roa-subjunctive-left-rail" style="height:3em;" | imperfect (ra)
|{{{impfsub1sg}}}
|{{{impfsub2sg}}}
|{{{impfsub3sg}}}
|{{{impfsub1pl}}}
|{{{impfsub2pl}}}
|{{{impfsub3pl}}}
|-
! class="roa-subjunctive-left-rail" style="height:3em;" | imperfect (si)
|{{{impfsisub1sg}}}
|{{{impfsisub2sg}}}
|{{{impfsisub3sg}}}
|{{{impfsisub1pl}}}
|{{{impfsisub2pl}}}
|{{{impfsisub3pl}}}
|-
! class="roa-person-number-header" style="height:.75em" colspan="8" |
|-
! class="roa-imperative-left-rail" style="height:3em;" colspan="2" | imperative
| —
|{{{impr2sg}}}
| —
| —
|{{{impr2pl}}}
| —
|}
</div></div>]=]
return require("Module:TemplateStyles")("Module:roa-verb/style.css") .. gsub(wikicode, "{{{[#!]?([a-z0-9|]+)}}}", repl)
end
return export