Module:sam-headword
Appearance
- The following documentation is located at Module:sam-headword/documentation. [edit] Categories were auto-generated by Module:module categorization. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module is used to implement Samaritan Aramaic headword-line templates. See an automatically generated list of the templates which it supports here.
local m_headword = require("Module:headword")
local com = require("Module:sam-common")
local export = {}
local pos_functions = {}
local lang = require("Module:languages").getByCode("sam")
local suffix_categories = {
["adjectives"] = true,
["adverbs"] = true,
["nouns"] = true,
["verbs"] = true,
}
local function get_params_list(args, argprefix)
local export = {}
i = 1
term = argprefix
while args[term] ~= nil and args[term] ~= "" do
table.insert(export, term)
i = i + 1
term = argprefix .. i
end
return export
end
local function make_params_array(args, params)
local export = {}
for _, param in ipairs(params) do
table.insert(export, args[param])
end
local pattern_link = ""
if args["pat"] and args["pat"] ~= "" and poscat ~= "verbs" then
table.insert(data.categories, "Samaritan Aramaic terms in the pattern " .. args["pat"])
local patfmt = require("Module:links").full_link({lang = lang, alt = args["pat"], tr = "-"})
pattern_link = " <small>[[Appendix:Samaritan Aramaic patterns/" .. args["pat"] .. "|[pattern: " .. patfmt .. "] ]]</small>"
return (m_headword.full_headword(data)) .. pattern_link
end
local function maybe_get_inflection(args, name, params, list, accel, is_construct)
if list then
params = get_params_list(args, params)
end
local args = require("Module:parameters").process(frame:getParent().args, params)
local tbl = {}
if type(params) ~= "table" then
params = {params}
end
for _, param in ipairs(params) do
local paramwv = param .. "wv"
local paramdwv = param .. "dwv"
if args[param] or args[paramwv] or args[paramdwv] then
tbl.label = name
tbl.accel = accel
if is_construct == true then
table.insert(tbl, com.gen_link_ending_with_makaf(args[param], args[paramwv], args[paramdwv]))
else
table.insert(tbl, com.gen_link(args[param], args[paramwv], args[paramdwv]))
end
end
if args[param] == "" or args[paramwv] == "" or args[paramdwv] == "" then
require('Module:debug').track("sam-noun/empty-form-param")
elseif args[param] ~= nil and args[paramwv] ~= nil then
require('Module:debug').track("sam-noun/param-and-paramwv")
end
end
return next(tbl) and tbl
end
-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
local args = {}
for k, v in pairs(frame:getParent().args) do
if v ~= "" then
args[k] = v
end
end
local poscat = frame.args[1] or error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")
if frame.args["auto"] and (args["auto"] == "" or not args["auto"]) then args["auto"] = frame.args["auto"] end
local data = {lang = lang, pos_category = poscat, categories = {}, heads = make_params_array(args, get_params_list(args, "head")), translits = make_params_array(args, get_params_list(args, "tr")), genders = {}, inflections = {}}
local head = args["head"]; if head == "" then head = nil end; data.heads[1] = head
data.sort_key = args["sort"]; if data.sort_key == "" then data.sort_key = nil end
if data.sort_key then
data.sort_key = data.sort_key .. "a" .. mw.title.getCurrentTitle().subpageText
end
local wv = args["wv"] or mw.title.getCurrentTitle().subpageText
local dwv = args["dwv"]
if not data.heads[1] then
if dwv then
data.heads[1] = wv .. " \\ " .. '<span class="inflection-table">' .. "[[" .. dwv .. "]]" .. "</span>" -- not really an inflection table but for the black links
else
data.heads[1] = wv
end
end
if dwv and mw.ustring.match(dwv, "%[%[") then
require('Module:debug').track("sam-noun/link-in-dwv")
end
if not (args["wv"] or args["dwv"] or args["head"]) then
require('Module:debug').track("sam-noun/no-nikud")
end
local vowels = "ࠖ ࠗ ࠘ ࠙ࠚ ࠛ ࠜ ࠝ ࠞ ࠟ ࠠ ࠡ ࠢ ࠣ ࠤ ࠥ ࠦ ࠧ ࠨ ࠩ ࠪ ࠫ ࠬ࠭"
local dagesh = "࠙"
local vowels_regex = "[" .. vowels .. "]"
local dagesh_regex = "[" .. dagesh .. "]"
if pos_functions[poscat] then
pos_functions[poscat](args, data, wv)
end
local function stemify_helper(letter, rest)
return (final_to_nonfinal[letter] or letter) .. rest
end
end
if pos_functions[poscat] then
pos_functions[poscat](args, data, wv)
end
pos_functions["adjectives"] = function(args, data)
-- table.insert(genders, "m")
if args["auto"] == nil or args["auto"] == "" then
-- Use only provided inflections
table.insert(data.inflections, maybe_get_inflection(args, "feminine", {"f", "f2"}, false))
table.insert(data.inflections, maybe_get_inflection(args, "masculine plural", {"mp", "mp2"}, false))
table.insert(data.inflections, maybe_get_inflection(args, "feminine plural", "fp", true))
else
require("Module:debug").track("sam-adj/auto")
-- Automatically generate inflections
local stem = args["stem"]
local stemwv = args["stemwv"]
local stemdwv = args["stemdwv"]
local e = false
if not stem then
if stemwv then
stem = com.remove_nikud(stemwv)
else
stem = stemify(mw.title.getCurrentTitle().subpageText)
if not stemdwv then
stemwv = stemify(args["wv"])
stemdwv = stemify(args["dwv"])
end
local fstemwv = stemwv and com.fix_nikud(stemwv)
local fstemdwv = stemdwv and com.fix_nikud(stemdwv)
if (fstemwv or fstemdwv) and (stem ~= nil or stem:match("ࠄ$")) and (fstemwv == nil or fstemwv:match("ࠄࠝ$")) and (fstemdwv == nil or fstemdwv:match("ࠄࠝ$")) then
e = true
stem = stem and stem:gsub("ࠄ$", "")
stemwv = fstemwv and fstemwv:gsub("ࠄࠝ$", "")
stemdwv = fstemdwv and fstemdwv:gsub("ࠄࠝ$", "")
end
end
end
stem, stemwv, stemdwv = com.process_wv_triad(stem, stemwv, stemdwv)
local f, fwv, fdwv = com.process_wv_triad(args["f"], args["fwv"], args["fdwv"])
local f2, f2wv, f2dwv = com.process_wv_triad(args["f2"], args["f2wv"], args["f2dwv"])
local mp, mpwv, mpdwv = com.process_wv_triad(args["mp"], args["mpwv"], args["mpdwv"])
local mp2, mp2wv, mp2dwv = com.process_wv_triad(args["mp2"], args["mp2wv"], args["mp2dwv"])
local fp, fpwv, fpdwv = com.process_wv_triad(args["fp"], args["fpwv"], args["fpdwv"])
if f ~= "-" then
if not (f or fwv or fdwv) then
f = stem and (stem .. "ࠄ")
fwv = stemwv and (stemwv .. "ࠄࠥ")
fdwv = stemdwv and (stemdwv .. "ࠄࠥ")
elseif f == "ࠕ" and not (fwv or fdwv) then
f = stem and (stem .. (e and "ࠉࠕ" or "ࠕ"))
fwv = stemwv and (e and (stemwv .. "ࠉࠢࠕ") or gen_fem_t(stemwv))
fdwv = stemdwv and (e and (stemdwv .. "ࠉࠢࠕ") or gen_fem_t(stemdwv))
end
if f2 == "ࠕ" and not (f2wv or f2dwv) then
f2 = stem and (stem .. (e and "ࠉࠕ" or "ࠕ"))
f2wv = stemwv and (e and (stemwv .. "ࠉࠢࠕ") or gen_fem_t(stemwv))
f2dwv = stemdwv and (e and (stemdwv .. "ࠉࠢࠕ") or gen_fem_t(stemdwv))
end
tbl = {label = "feminine", com.gen_link(f, fwv, fdwv)}
if f2 or f2wv or f2dwv then
table.insert(tbl, com.gen_link(f2, f2wv, f2dwv))
end
table.insert(data.inflections, tbl)
end
if mp ~= "-" then
if not (mp or mpwv or mpdwv) then
mp = stem and (stem .. "ࠉࠌ")
mpwv = stemwv and (stemwv .. "ࠉࠩࠌ")
mpdwv = stemdwv and (stemdwv .. "ࠉࠩࠌ")
end
tbl = {label = "masculine plural", com.gen_link(mp, mpwv, mpdwv)}
if mp2 or mp2wv or mp2dwv then
table.insert(tbl, com.gen_link(mp2, mp2wv, mp2dwv))
end
table.insert(data.inflections, tbl)
end
if fp ~= "-" then
if not (fp or fpwv or fpdwv) then
fp = stem and (stem .. "ࠅࠕ")
fpwv = stemwv and (stemwv .. "ࠅࠫࠕ")
fpdwv = stemdwv and (stemdwv .. "ࠅࠫࠕ")
end
tbl = {label = "feminine plural", com.gen_link(fp, fpwv, fpdwv)}
table.insert(data.inflections, tbl)
end
end
end
pos_functions["determiners"] = function(args, data, wv)
if args["g"] == "m" or args["g"] == "m-p" then
table.insert(data.genders, args["g"])
table.insert(data.inflections, maybe_get_inflection(args, "feminine counterpart", "f", true))
elseif args["g"] == "f" or args["g"] == "f-p" then
table.insert(data.genders, args["g"])
table.insert(data.inflections, maybe_get_inflection(args, "masculine counterpart", "m", false))
elseif args["g"] == "m-f" or args["g"] == "m-f-p" then
table.insert(data.genders, args["g"])
end
end
pos_functions["nouns"] = function(args, data, wv)
if args["g"] == "m" or args["g"] == "f" or args["g"] == "m-f" then
table.insert(data.genders, args["g"])
if args["sg"] ~= nil then
require('Module:debug').track("sam-noun/sg-for-head")
end
elseif args["g"] == "m-d" or args["g"] == "f-d" or args["g"] == "m-f-d" then
table.insert(data.genders, args["g"])
table.insert(data.categories, "Samaritan dualia tantum")
table.insert(data.inflections, maybe_get_inflection(args, "singular indefinite", "sg", false))
elseif args["g"] == "m-p" or args["g"] == "f-p" or args["g"] == "m-f-p" then
table.insert(data.genders, args["g"])
table.insert(data.categories, "Samaritan Aramaic pluralia tantum")
table.insert(data.inflections, maybe_get_inflection(args, "singular indefinite", "sg", false))
elseif args["g"] == "" or args["g"] == nil then
table.insert(data.genders, "?")
table.insert(data.categories, "Requests for gender in Samaritan Aramaic entries")
end
-- Dual forms rare enough that there's no need for without/missing categoristion
table.insert(data.inflections, maybe_get_inflection(args, "dual indefinite", "dual", true))
if args["pl"] == "-" then
table.insert(data.inflections, {label = "no plural forms"})
table.insert(data.categories, "Samaritan Aramaic nouns without plural forms")
elseif args["pl"] == "" or args["pl"] == nil then
table.insert(data.categories, "Requests for plural forms in Samaritan Aramaic noun entries")
else
table.insert(data.inflections, maybe_get_inflection(args, "plural indefinite", "pl", true, {form = "p", lemma = wv}))
if args["g"] == "m" and mw.ustring.sub(com.remove_nikud(args["pl"]), -2, -1) == "ࠅࠕ" then
table.insert(data.categories, "Samaritan Aramaic masculine nouns with plurals ending in ־ࠅࠕ")
elseif args["g"] == "f" and mw.ustring.sub(com.remove_nikud(args["pl"]), -2, -1) == "ࠉࠌ" then
table.insert(data.categories, "Samaritan Aramaic feminine nouns with plurals ending in ־ࠉࠌ")
elseif mw.ustring.sub(com.remove_nikud(args["pl"]), -3, -1) == "ࠉࠉࠌ" then
table.insert(data.categories, "Samaritan Aramaic nouns with plurals ending in ־ࠉࠉࠌ")
end
end
if args["cons"] == "-" then
table.insert(data.inflections, {label = "no construct forms"})
table.insert(data.categories, "Samaritan Aramaic nouns without construct forms")
else
if args["cons"] == "" or args["cons"] == nil then
table.insert(data.categories, "Samaritan Aramaic noun entries missing singular construct forms")
else
table.insert(data.inflections, maybe_get_inflection(args, "singular construct", "cons", true, {form = "cons|s", lemma = wv}, true))
end
table.insert(data.inflections, maybe_get_inflection(args, "dual construct", "dualcons", true , nil, true))
if (args["plcons"] == "" or args["plcons"] == nil) and args["pl"] ~= "-" then
table.insert(data.categories, "Samaritan Aramaic noun entries missing plural construct forms")
else
table.insert(data.inflections, maybe_get_inflection(args, "plural construct", "plcons", true, {form = "cons|p", lemma = wv}, true))
end
end
table.insert(data.inflections, maybe_get_inflection(args, "masculine counterpart", "m", true))
table.insert(data.inflections, maybe_get_inflection(args, "feminine counterpart", "f", true))
if args["g"] == "m" and mw.ustring.sub((com.remove_nikud(args["wv"] or args["dwv"] or mw.title.getCurrentTitle().subpageText)), -1) == "ࠕ" then
table.insert(data.categories, "Samaritan Aramaic masculine nouns ending in ־ࠕ")
elseif args["g"] == "m" and mw.ustring.sub((com.remove_nikud(args["wv"] or args["dwv"] or mw.title.getCurrentTitle().subpageText)), -1) == "ࠄ" then
table.insert(data.categories, "Samaritan Aramaic masculine nouns ending in ־ࠄ")
end
end
pos_functions["numerals"] = function(args, data)
table.insert(data.inflections, maybe_get_inflection(args, "construct", "cons", true))
table.insert(data.inflections, maybe_get_inflection(args, "masculine counterpart", "m", true))
table.insert(data.inflections, maybe_get_inflection(args, "feminine counterpart", "f", true))
end
pos_functions["pronouns"] = function(args, data)
if args["g"] == "m" or args["g"] == "f" or args["g"] == "m-p" or args["g"] == "f-p" then
table.insert(data.genders, args["g"])
elseif args["g"] == "m-f" then
table.insert(data.genders, "m")
table.insert(data.genders, "f")
elseif args["g"] == "m-f-p" then
table.insert(data.genders, "m-p")
table.insert(data.genders, "f-p")
elseif args["n"] then
require('Module:debug').track("sam-pron/param-n")
end
end
pos_functions["proper nouns"] = function(args, data, wv)
if args["pl"] and args["pl"] ~= "-" and args["pl"] ~= "" then
table.insert(data.inflections, maybe_get_inflection(args, "plural indefinite", "pl", true, {form = "p", lemma = wv}))
if args["g"] == "m" and mw.ustring.sub(com.remove_nikud(args["pl"]), -2, -1) == "ࠅࠕ" then
table.insert(data.categories, "Samaritan Aramaic masculine nouns with plurals ending in ־ࠅࠕ")
elseif args["g"] == "f" and mw.ustring.sub(com.remove_nikud(args["pl"]), -2, -1) == "ࠉࠌ" then
table.insert(data.categories, "Samaritan Aramaic feminine nouns with plurals ending in ־ࠉࠌ")
elseif mw.ustring.sub(com.remove_nikud(args["pl"]), -3, -1) == "ࠉࠉࠌ" then
table.insert(data.categories, "Samaritan Aramaic nouns with plurals ending in ־ࠉࠉࠌ")
end
end
if args["g"] == "m" or args["g"] == "f" or args["g"] == "m-f" then
table.insert(data.genders, args["g"])
elseif args["g"] == "m-d" or args["g"] == "f-d" or args["g"] == "m-f-d" then
table.insert(data.genders, args["g"])
table.insert(data.categories, "Samaritan Aramaic dualia tantum")
elseif args["g"] == "m-p" or args["g"] == "f-p" or args["g"] == "m-f-p" then
table.insert(data.genders, args["g"])
table.insert(data.categories, "Samaritan Aramaic pluralia tantum")
elseif args["g"] == "" or args["g"] == nil then
table.insert(data.categories, "Requests for gender in Samaritan Aramaic proper noun entries")
elseif args["g"] == "-" then --surnames don't really have gender
table.insert(data.categories, "Samaritan Aramaic proper nouns without gender")
else
table.insert(data.genders, "?")
end
end
local weakroots = {
["ࠐ"] = {
["ࠀ"] = true,
["ࠄ"] = true,
["ࠇ"] = true,
["ࠉ"] = true,
["ࠋ"] = true,
["ࠍ"] = true,
["ࠏ"] = true,
},
["ࠏ"] = {
["ࠀ"] = true,
["ࠄ"] = true,
["ࠅ"] = true,
["ࠇ"] = true,
["ࠉ"] = true,
["ࠏ"] = true,
["ࠒ"] = true,
},
["ࠋ"] = {
["ࠀ"] = true,
["ࠄ"] = true,
["ࠇ"] = true,
["ࠍ"] = true,
["ࠏ"] = true,
},
}
return export
end