Module:da-utilities

From Wiktionary, the free dictionary
Jump to navigation Jump to search
This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local lang = require("Module:languages").getByCode("da")
local m_utils = require("Module:utilities")

local export = {}

function export.determine_class(frame)
	local args = frame.args
	local ret = ""
	local cat = {}
	--local head = mw.title.getCurrentTitle().text
	if args.class then
		class = args.class
	elseif string.sub(args[4], -2, -1) == "de" or args[4].sub(-2, -1) == "te" then
		return "weak verb" .. m_utils.format_categories({"Danish weak verbs"})
	else
		local _, _, pres_vowel = string.find(args[1], "([aeiouyæøå])-^")
		local _, _, past_vowel = string.find(args[4], "([aeiouyæøå])-^")
		local _, _, perf_vowel = string.find(args[6], "([aeiouyæøå])-et")
		local class = nil
		
		if pres_vowel == "i" and past_vowel == "e" then
			class = 1
		elseif pres_vowel == "y" and past_vowel == "ø" then
			class = 2
		elseif string.find(pres_vowel, "[æiy]") and past_vowel == "a" then
			if perf_vowel == "u" then
				class = 3
			elseif perf_vowel == "å" then
				class = 4
			end
		elseif string.find(pres_vowel, "[æie]") and past_vowel == "a" and string.find(perf_vowel, "[æe]") then
			class = 5
		elseif string.find(pres_vowel, "[æa]") and past_vowel == "o" then
			class = 6
		end
	end
	
	
	return "class " .. class .. " strong verb" .. m_utils.format_categories({"Danish class " .. class .. " strong verbs"})

end