Module:anui-headword: Difference between revisions

From Linguifex
Jump to navigation Jump to search
No edit summary
No edit summary
Line 13: Line 13:
local function glossary_link(entry, text)
local function glossary_link(entry, text)
text = text or entry
text = text or entry
return "[[w:Appendix:Glossary#" .. entry .. "|" .. text .. "]]"
return "[[wikt:Appendix:Glossary#" .. entry .. "|" .. text .. "]]"
end
end



Revision as of 11:56, 7 July 2021



local match = mw.ustring.match
local u = mw. ustring.char
local gsub = mw.ustring.gsub

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

local export = {}

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

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

local function redup(word)
	word = word:gsub("([ḛḭṵaɔ]" .. TILDEB .. "?)", {["ḛ"] = "è", ["ḭ"] = "ì", ["ṵ"] = "ù", ["a" .. TILDEB] = "à", ["ɔ" .. TILDEB] = "ò"})
	
	local consonant = "[ǃǂǁʘʼxqrʛɴɬšṣchjklmptŋṉṭṯ]"
	local vowel = "[aeiouàèìòùʼ]"
	local C = match(word, consonant .. "*")
	
	return word
end

function export.show(frame)
	local args = frame:getParent().args
	local data = {lang = lang, pos_category = deabb[args[1]], categories = {}, inflections = {},}
	local word = mw.title.getCurrentTitle().text or args["w"]
	local pos = args[1]; local f = args[2]
	
	if f == '-' then
		if pos == "adj" then
			table.insert(data.inflections, {label = "not " .. glossary_link("comparable")})
			table.insert(data.categories, lang:getCanonicalName() .. " uncomparable adjectives")
		end
	elseif not pos == "v" then
		table.insert(data.inflections, {label = glossary_link("comparative"), redup(word)})
		if pos == "adverbs" then table.insert(data.categories, lang:getCanonicalName() .. " comparative " .. pos) end
	else
		table.insert(data.inflections, {label = glossary_link("applicative"), redup(word)})
	end
	
	return require('Module:headword').full_headword(data)
end

return export