45,660
edits
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
local | local export = {} | ||
local pos_functions = {} | |||
local sub = mw.ustring.sub | |||
local find = mw.ustring.find | |||
local match = mw.ustring.match | |||
local gmatch = mw.ustring.gmatch | |||
local gsub = mw.ustring.gsub | |||
local u = mw.ustring.char | |||
local split = mw.text.split | |||
local gsplit = mw.text.gsplit | |||
local PAGENAME = mw.title.getCurrentTitle().text | |||
local NAMESPACE = mw.title.getCurrentTitle().nsText | |||
local SUBPAGENAME = mw.title.getCurrentTitle().subpageText | |||
local | local legal_gender = { | ||
["in"] = true, | |||
["an"] = true, | |||
} | |||
local gender_names = { | |||
["in"] = "inanimate", | |||
["an"] = "animate", | |||
} | |||
local lang = require("Module:languages").getByCode("siwa") | |||
local m_n = require("Module:siwa-noun") | |||
function | local function glossary_link(entry, text) | ||
return "[[wikt:Appendix:Glossary#" .. entry .. "|" .. (text or entry) .. "]]" | |||
end | end | ||
Line 14: | Line 35: | ||
-- This is the only function that can be invoked from a template. | -- This is the only function that can be invoked from a template. | ||
function export.show(frame) | function export.show(frame) | ||
if NAMESPACE == "Template" and SUBPAGENAME ~= "doc" then return end | |||
local parent_args = frame:getParent().args | |||
local | |||
local | local poscat = frame.args[1] or error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.") | ||
if | local class = frame.args[2]; if class == "" then class = nil end | ||
local data = { | |||
lang = lang, | |||
heads = {}, | |||
inflections = {}, | |||
genders = {}, | |||
pos_category = poscat, | |||
categories = {"Siwa " .. poscat} | |||
} | |||
if poscat | if pos_functions[poscat] then | ||
pos_functions[poscat](class, parent_args, data) | |||
end | end | ||
return | return require("Module:headword").full_headword(data) | ||
end | end | ||
pos_functions.nouns = function(class, args, data) | |||
local params = { | |||
function | [1] = {required = true}, | ||
local | [2] = {}, | ||
[ | ["m"] = {list = true}, | ||
[ | ["head"] = {default = PAGENAME}, | ||
[" | } | ||
[" | |||
local args = require("Module:parameters").process(args, params) | |||
data.heads = {args["head"]} | |||
table.insert(data.genders, args[1]) | |||
if args[2] then table.insert(data.genders, args[2]) end | |||
table.insert(data.inflections, args.m or m_n.head) | |||
inflections[1].label = "marked" | |||
end | end | ||
function | pos_functions.adjectives = function(class, args, data) | ||
local | local params = { | ||
[1] = {list = "eq"}, | |||
[2] = {list = "comp"}, | |||
[3] = {list = "sup"}, | |||
["unc"] = {type = "boolean"}, | |||
["indecl"] = {type = "boolean"}, | |||
["head"] = {}, | |||
} | |||
local args = require("Module:parameters").process(args, params) | |||
local isdet = data.pos_category == "determiners" | |||
data.heads = {args["head"]} | |||
if | table.insert(data.categories, "High Valyrian " .. data.pos_category) | ||
table.insert(data.inflections, {label = " | if args["unc"] or isdet then | ||
table.insert(data.inflections, {label = "not " .. glossary_link("comparable")}) | |||
if not isdet then table.insert(data.categories, "High Valyrian uncomparable adjectives") end | |||
elseif args["indecl"] then | |||
table.insert(data.inflections, {label = "superlative", | table.insert(data.inflections, {label = glossary_link("indeclinable")}) | ||
table.insert(data.categories, "High Valyrian indeclinable " .. data.pos_category) | |||
else | |||
args[1] = require("Module:qhv-adj/head").fetch("eq") | |||
args[2] = require("Module:qhv-adj/head").fetch("comp") | |||
args[3] = require("Module:qhv-adj/head").fetch("sup") | |||
args[1].label = glossary_link("equative") | |||
args[2].label = glossary_link("comparative") | |||
args[3].label = glossary_link("superlative") | |||
table.insert(data.inflections, args[1]) | |||
table.insert(data.inflections, args[2]) | |||
table.insert(data.inflections, args[3]) | |||
end | end | ||
end | end | ||
function | pos_functions["proper nouns"] = pos_functions.nouns | ||
local | pos_functions["determiners"] = pos_functions.adjectives | ||
pos_functions.verbs = function(class, args, data) | |||
local params = { | |||
[1] = {list = "pres"}, | |||
[2] = {list = "subj"}, | |||
[3] = {list = "pp"}, | |||
["head"] = {}, | |||
} | |||
local args = require("Module:parameters").process(args, params) | |||
data.heads = {args["head"]} | |||
table.insert(data.categories, "High Valyrian " .. data.pos_category) | |||
args[1] = require("Module:qhv-verb/head").fetch("act_ind_prs_1sg") | |||
table.insert(data.inflections, | args[2] = require("Module:qhv-verb/head").fetch("act_sub_prs_1sg") | ||
args[3] = require("Module:qhv-verb/head").fetch("act_part_prf") | |||
args[1].label = "first-person singular present indicative" | |||
args[2].label = "first-person singular present subjunctive" | |||
args[3].label = "perfect participle" | |||
table.insert(data.inflections, args[1]) | |||
table.insert(data.inflections, args[2]) | |||
table.insert(data.inflections, args[3]) | |||
end | end | ||
return export | return export |