Module:kilta-headword: Difference between revisions

From Linguifex
Jump to navigation Jump to search
No edit summary
No edit summary
Line 20: Line 20:
local w = split(word, "%s")
local w = split(word, "%s")
if w[n]:match("[kh]wa$") or w[n]:match("a$") then
--[[if w[n]:match("[kh]wa$") or w[n]:match("a$") then
w[n] = sub(word, 1, -1) .. "úr"
w[n] = sub(word, 1, -1) .. "úr"
elseif w[n]:match("ës$") or w[n]:match("uin$") or w[n]:match("[str]$") then
elseif w[n]:match("ës$") or w[n]:match("uin$") or w[n]:match("[str]$") then
Line 26: Line 26:
elseif word:match("[nml]$") then
elseif word:match("[nml]$") then
w[n] = word .. "ur"
w[n] = word .. "ur"
end
end]]
return {label = "plural", table.concat(w)}
return {label = "plural", n}
end
end



Revision as of 17:18, 22 April 2024

Documentation for this module may be created at Module:kilta-headword/doc

local match = mw.ustring.match
local u = mw.ustring.char
local gsub = mw.ustring.gsub
local sub = mw.ustring.sub
local split = mw.text.split

local TILDEB = u(0x0330) -- COMBINING TILDE BELOW ̰◌

local export = {}

local lang = require("Module:languages").getByCode("kilta")
local deabb = {["adj"] = "adjectives", ["v"] = "verbs", ["adv"] = "adverbs", ["n"] = "nouns"}

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

local function plural(word, n)
	local w = split(word, "%s")
	
	--[[if w[n]:match("[kh]wa$") or w[n]:match("a$") then
		w[n] = sub(word, 1, -1) .. "úr"
	elseif w[n]:match("ës$") or w[n]:match("uin$") or w[n]:match("[str]$") then
		w[n] = word .. "á"
	elseif word:match("[nml]$") then
		w[n] = word .. "ur"
	end]]
	
	return {label = "plural", n}
end

function export.show(frame)
	
	local params = {
		[1] = {},
		["pl"] = {list = true},
		["w"] = {default = mw.title.getCurrentTitle().text},
		["n"] = {type = number, default = 1}
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	local word = args.w
	local pos = args[1]; local pl = args.pl
	local data = {lang = lang, pos_category = deabb[pos], heads = {word}, categories = {}, inflections = {},}

	
	if pl[1] == '-' then
		if pos == "n" then
			table.insert(data.inflections, {label = glossary_link("uncountable")})
			table.insert(data.categories, lang:getCanonicalName() .. " uncountable " .. deabb[pos])
		end
	--[=[ elseif pos ~= "v" then
		table.insert(data.inflections, {label = glossary_link("comparative"), redup(word)})
		if pos == "adv" then table.insert(data.categories, lang:getCanonicalName() .. " comparative " .. deabb[pos]) end ]=]
	else
		if pl[1] then
			pl.label = "plural"
			table.insert(data.inflections, pl)
		else
			table.insert(data.inflections, plural(word, args.n))
		end
	end
	
	return require('Module:headword').full_headword(data)
end

return export