Module:qay-headword: Difference between revisions

From Linguifex
Jump to navigation Jump to search
No edit summary
No edit summary
 
(20 intermediate revisions by the same user not shown)
Line 18: Line 18:
["in"] = true, ["i"] = true,
["in"] = true, ["i"] = true,
["an"] = true, ["a"] = true,
["an"] = true, ["a"] = true,
["in-p"] = true, ["an-p"] = true,
["?"] = true,
["?"] = true,
}
}


local gender_names = {
local gender_names = {
["in"] = "inanimate", ["i"] = "inanimate",
["in"] = "in", ["i"] = "in", ["in-p"] = "in-p",
["an"] = "animate", ["a"] = "animate",
["an"] = "an", ["a"] = "an", ["an-p"] = "an-p",
["?"] = "unknown",
["?"] = "unknown",
}
}


local lang = require("Module:languages").getByCode("qay")
local lang = require("Module:languages").getByCode("qay")
local sc = require("Module:scripts").getByCode("Ayer")
local m_data = require("Module:qay-noun/data")
local m_data = require("Module:qay-noun/data")


Line 49: Line 51:
local parent_args = frame:getParent().args
local parent_args = frame:getParent().args
local head = '<span style="font-family:Tagati">' .. (parent_args[2] or PAGENAME) .. '</span>'
local head = parent_args[2] or PAGENAME
local translit = PAGENAME
local translit = PAGENAME
Line 57: Line 59:
local data = {
local data = {
lang = lang,
lang = lang,
heads = head,
heads = {head},
translits = translit,
translits = {translit},
inflections = {},
inflections = {},
genders = {},
genders = {},
pos_category = poscat,
pos_category = poscat,
categories = {"Contionary"},
categories = {"Contionary"},
affix = frame.args["affix"]
}
}
Line 77: Line 80:
[2] = {required = true},
[2] = {required = true},
["nopl"] = {},
["nopl"] = {},
["pl"] = {},
["pl"] = {list=true},
["affix"] = {list=true},
}
}
local args = require("Module:parameters").process(args, params)
local args = require("Module:parameters").process(args, params)
--data.heads = {args["head"]}
--data.heads = {args["head"]}
data.affix = args.affix
table.insert(data.genders, args[1])
table.insert(data.genders, gender_names[args[1]])
table.insert(data.categories, "Ayeri " .. (args[1] == "?" and "" or gender_names[args[1]]) .. " " .. data.pos_category)
--table.insert(data.categories, lang:getCanonicalName() .. " " .. (args[1] == "?" and "" or gender_names[args[1]]) .. " " .. data.pos_category)
if not args["nopl"] then
local plurals = {}
args["pl"] = generate_plural(PAGENAME)
if not args["nopl"] and not match(gender_names[args[1]],"p") then
plurals = #args.pl ~= 0 and args.pl or generate_plural(PAGENAME, gender_names[args[1]])
for i, form in ipairs(args["pl"]) do
for i, form in ipairs(plurals) do
args["pl"][i] = {term = form}
plurals[i] = {term = form}
plurals[i].sc = require("Module:scripts").getByCode("Latn")
end
end
args["pl"].label = "plural"
plurals.label = "plural"
table.insert(data.inflections, args["pl"])
table.insert(data.inflections, plurals)
else
table.insert(data.categories, lang:getCanonicalName() .. " uncountable nouns")
table.insert(data.inflections, {label = glossary_link("uncountable")})
end
end
end
end


--[[pos_functions.adjectives = function(class, args, data)
pos_functions.adjectives = function(class, args, data)
local params = {
local params = {
[1] = {list = "eq"},
[1] = {},
[2] = {list = "comp"},
[3] = {list = "sup"},
["unc"] = {type = "boolean"},
["unc"] = {type = "boolean"},
["indecl"] = {type = "boolean"},
["head"] = {},
["head"] = {},
["affix"] = {list=true},
}
}
local args = require("Module:parameters").process(args, params)
local args = require("Module:parameters").process(args, params)
local isdet = data.pos_category == "determiners"
data.heads = {args["head"] or args[1]}
data.heads = {args["head"]}
data.affix = args.affix
table.insert(data.categories, "High Valyrian " .. data.pos_category)
table.insert(data.categories, "Ayeri " .. data.pos_category)
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 = 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


pos_functions["proper nouns"] = pos_functions.nouns
--[[pos_functions["proper nouns"] = pos_functions.nouns
pos_functions["determiners"] = pos_functions.adjectives
pos_functions["determiners"] = pos_functions.adjectives



Latest revision as of 18:57, 8 August 2024



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 legal_gender = {
	["in"] = true, ["i"] = true,
	["an"] = true, ["a"] = true,
	["in-p"] = true, ["an-p"] = true,
	["?"] = true,
}

local gender_names = {
	["in"] = "in", ["i"] = "in", ["in-p"] = "in-p",
	["an"] = "an", ["a"] = "an", ["an-p"] = "an-p",
	["?"] = "unknown",
}

local lang = require("Module:languages").getByCode("qay")
local sc = require("Module:scripts").getByCode("Ayer")
local m_data = require("Module:qay-noun/data")

local function glossary_link(entry, text)
	text = text or entry
	return "[[wikt:Appendix:Glossary#" .. entry .. "|" .. text .. "]]"
end

local function generate_plural(word, gender)
	local plural = {}
	for alt in gmatch(require("Module:qay-noun/head").pass_to_module(word, "top_p", gender), "[^,]+") do
		table.insert(plural, alt)
	end
	return plural
end

-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
	if NAMESPACE == "Template" and SUBPAGENAME ~= "doc" then return end
	local parent_args = frame:getParent().args
	
	local head = parent_args[2] or PAGENAME
	local translit = PAGENAME
	
	local poscat = frame.args[1] or error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")
	local class = frame.args[2]; if class == "" then class = nil end
	
	local data = {
		lang = lang,
		heads = {head},
		translits = {translit},
		inflections = {},
		genders = {},
		pos_category = poscat,
		categories = {"Contionary"},
		affix = frame.args["affix"]
	}
	
	if pos_functions[poscat] then
		pos_functions[poscat](class, parent_args, data)
	end
	
	return require("Module:headword").full_headword(data)
end

pos_functions.nouns = function(class, args, data)
	local params = {
		[1] = {required = true},
		[2] = {required = true},
		["nopl"] = {},
		["pl"] = {list=true},
		["affix"] = {list=true},
	}
	
	local args = require("Module:parameters").process(args, params)
	--data.heads = {args["head"]}
	data.affix = args.affix
	
	table.insert(data.genders, gender_names[args[1]])
	--table.insert(data.categories, lang:getCanonicalName() .. " " .. (args[1] == "?" and "" or gender_names[args[1]]) .. " " .. data.pos_category)
	
	local plurals = {}
	
	if not args["nopl"] and not match(gender_names[args[1]],"p") then
		plurals = #args.pl ~= 0 and args.pl or generate_plural(PAGENAME, gender_names[args[1]])
			
		for i, form in ipairs(plurals) do
			plurals[i] = {term = form}
			plurals[i].sc = require("Module:scripts").getByCode("Latn")
		end
			
		plurals.label = "plural"
		
		table.insert(data.inflections, plurals)
	else
		table.insert(data.categories, lang:getCanonicalName() .. " uncountable nouns")
		table.insert(data.inflections, {label = glossary_link("uncountable")})
	end
end

pos_functions.adjectives = function(class, args, data)
	local params = {
		[1] = {},
		["unc"] = {type = "boolean"},
		["head"] = {},
		["affix"] = {list=true},
	}
	
	local args = require("Module:parameters").process(args, params)
	data.heads = {args["head"] or args[1]}
	data.affix = args.affix
	
	table.insert(data.categories, "Ayeri " .. data.pos_category)
end

--[[pos_functions["proper nouns"] = pos_functions.nouns
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")
	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]]

return export