Modul:sla-headword

Üdvözlöm, Ön a Modul:sla-headword szó jelentését keresi. A DICTIOUS-ban nem csak a Modul:sla-headword szó összes szótári jelentését megtalálod, hanem megismerheted az etimológiáját, a jellemzőit és azt is, hogyan kell a Modul:sla-headword szót egyes és többes számban mondani. Minden, amit a Modul:sla-headword szóról tudni kell, itt található. A Modul:sla-headword szó meghatározása segít abban, hogy pontosabban és helyesebben fogalmazz, amikor beszélsz vagy írsz. AModul:sla-headword és más szavak definíciójának ismerete gazdagítja a szókincsedet, és több és jobb nyelvi forráshoz juttat.

A modult a Modul:sla-headword/doc lapon tudod dokumentálni

local export = {}

local lang = require("Module:languages").getByCode("sla-pro")

local GRAVE = mw.ustring.char(0x300)
local TILDE = mw.ustring.char(0x303)
local MACRON = mw.ustring.char(0x304)
local CARON = mw.ustring.char(0x30C)
local DGRAVE = mw.ustring.char(0x30F)
local INVBREVE = mw.ustring.char(0x311)
local OGONEK = mw.ustring.char(0x328)


-- This could be moved to the common module
local function are_accents_valid(word)
	-- Split into syllables
	local rest = word:gsub("^%*", "")
	local consonants, vowel
	local syllables = {}
	
	while true do
		consonants, rest = mw.ustring.match(rest, "^(*)(.-)$")
		
		-- Shift initial l, r to previous syllable where necessary
		if #syllables > 0 and mw.ustring.find(consonants, "^.") then
			syllables.vowel = syllables.vowel .. consonants:sub(1, 1)
			consonants = consonants:sub(2)
		end
		
		rest = mw.ustring.toNFD(rest)
		vowel, rest = mw.ustring.match(rest, "^(*)(.-)$")
		
		if not vowel then
			break
		end
		
		rest = mw.ustring.toNFC(rest)
		
		-- Recombine ě, ę, ǫ
		if vowel:sub(1, 1) == "e" and vowel:find(CARON, nil, true) then
			vowel = vowel:gsub("^e", "ě")
			vowel = vowel:gsub(CARON, "")
		elseif vowel:sub(1, 1) == "e" and vowel:find(OGONEK, nil, true) then
			vowel = vowel:gsub("^e", "ę")
			vowel = vowel:gsub(OGONEK, "")
		elseif vowel:sub(1, 1) == "o" and vowel:find(OGONEK, nil, true) then
			vowel = vowel:gsub("^o", "ǫ")
			vowel = vowel:gsub(OGONEK, "")
		end
		
		local dia = mw.ustring.sub(vowel, 2)
		vowel = mw.ustring.sub(vowel, 1, 1)
		
		table.insert(syllables, {consonants = consonants, vowel = vowel, dia = dia})
	end
	
	-- Check each syllable's diacritics
	for i, syllable in ipairs(syllables) do
		if syllable.dia ~= "" then
			-- Historical short or long vowel?
			if mw.ustring.find(syllable.vowel, "^$") then
				if i == 1 then
					if not (syllable.dia == GRAVE or syllable.dia == DGRAVE) then
						-- First syllable only allows short rising and falling
						return false
					end
				elseif i == #syllables and mw.ustring.find(syllable.vowel, "^$") then
					-- Final yer doesn't allow any diacritics
					return false
				elseif not (syllable.dia == GRAVE) then
					-- Any remaining vowels allow only short rising
					return false
				end
			else
				-- Acute and macron allowed on any long syllable
				if not (syllable.dia == GRAVE or syllable.dia == MACRON) then
					if i == 1 then
						if not (syllable.dia == TILDE or syllable.dia == INVBREVE) then
							-- First syllable only allows neoacute and circumflex
							return false
						end
					elseif i == #syllables then
						-- Last syllable doesn't allow any of the remaining diacritics
						return false
					elseif not (syllable.dia == TILDE) then
						-- Medial syllable only allows neoacute
						return false
					end
				end
			end
		end
	end
	
	return true
end

-- Checks if the accents in the headword conform to ].
local function check_accents(heads, categories)
	for _, head in ipairs(heads) do
		if not are_accents_valid(head) then
			table.insert(categories, lang:getCanonicalName() .. " entries with invalid diacritics")
		end
	end
end


function export.adjective(frame)
	local params = {
		 = {list = true},
		
		 = {},
		 = {list = true},
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	local data = {lang = lang, pos_category = "adjectives", categories = {}, heads = args, inflections = {}}
	
	if args == "adjective-forming suffixes" then
		data.pos_category = "suffixes"
		table.insert(data.categories, lang:getCanonicalName() .. " " .. args)
	end
	
	-- Comparative
	if args then
		args.label = "comparative"
		table.insert(data.inflections, args)
	end
	
	check_accents(data.heads, data.categories)
	
	return require("Module:headword").full_headword(data)
end


function export.adverb(frame)
	local params = {
		 = {},
		 = {},
		 = {list = true},
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	local data = {lang = lang, pos_category = "adverbs", categories = {}, heads = args}
	
	if args == "adverb-forming suffixes" then
		data.pos_category = "suffixes"
		table.insert(data.categories, lang:getCanonicalName() .. " " .. args)
	end
	
	if args then
		table.insert(data.categories, lang:getCanonicalName() .. " " .. args)
	end
	
	check_accents(data.heads, data.categories)
	
	return require("Module:headword").full_headword(data)
end


function export.noun(frame)
	local params = {
		 = {list = true, default = "?"},
		
		 = {},
		 = {list = true},
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	local data = {lang = lang, pos_category = "nouns", categories = {}, heads = args, genders = {}}
	
	if args == "noun-forming suffixes" then
		data.pos_category = "suffixes"
		table.insert(data.categories, lang:getCanonicalName() .. " " .. args)
	end
	
	-- Genders
	for i, val in ipairs(args) do
		if val == "m" or val == "f" or val == "n" or val == "m-d" or val == "f-d" or val == "n-d" or val == "m-p" or val == "f-p" or val == "n-p" then
			table.insert(data.genders, val)
			
			if val == "m-d" or val == "f-d" or val == "n-d" then
				table.insert(data.categories, lang:getCanonicalName() .. " dualia tantum")
			elseif val == "m-p" or val == "f-p" or val == "n-p" then
				table.insert(data.categories, lang:getCanonicalName() .. " pluralia tantum")
			end
		else
			table.insert(data.genders, "?")
		end
	end
	
	check_accents(data.heads, data.categories)
	
	return require("Module:headword").full_headword(data)
end


function export.verb(frame)
	local params = {
		 = {list = true},
		 = {},
		 = {list = true},
		 = {list = true},
		 = {list = true},
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	local data = {lang = lang, pos_category = "verbs", categories = {}, heads = args, genders = {}, inflections = {}}
	
	if args == "verb-forming suffixes" then
		data.pos_category = "suffixes"
		table.insert(data.categories, lang:getCanonicalName() .. " " .. args)
	end
	
	-- Aspects
	for i, val in ipairs(args) do
		if val == "impf" or val == "pf" then
			table.insert(data.genders, val)
			
			if val == "impf" then
				table.insert(data.categories, lang:getCanonicalName() .. " imperfective verbs")
			else
				table.insert(data.categories, lang:getCanonicalName() .. " perfective verbs")
			end
		else
			table.insert(data.genders, "?")
		end
	end
	
	-- Imperfective equivalent
	if args then
		args.label = "imperfective"
		table.insert(data.inflections, args)
	end
	
	-- Perfective equivalent
	if args then
		args.label = "perfective"
		table.insert(data.inflections, args)
	end
	
	check_accents(data.heads, data.categories)
	
	return require("Module:headword").full_headword(data)
end


return export