Module:Nb-noun

local lang = require("Module:languages").getByCode("nb")

local export = {}

function export.regular(frame)
	local PAGENAME = mw.title.getCurrentTitle().text
	local args = frame:getParent().args
	local class = frame.args[1]
	
	local data = {lang = lang, pos_category = "nouns", categories = {}, genders = {}, inflections = {}}
	
	-- Gather parameters
	local root = PAGENAME:gsub("e$", "")
	
	local root_pl = nil
	local root_sg = nil
	if args[1] and args[1] ~= '' and not args[2] then
		root_sg = args[1]
		root_pl = args[1]
	elseif args[2] and args[2] ~= '' then
		root_pl = args[2]
		if args[1] and args[1] ~= '' then
			root_sg = args[1]
		end
	end
	
	local gen_dsg = args['gen_dsg']; if gen_dsg == "" then gen_dsg = nil end
	local uncountable = class:find('u$')
	
	if not root_pl then
		if PAGENAME:find("kel$") then
			root_pl = PAGENAME:gsub("k?kel$", "kl")
		elseif PAGENAME:find("tel$") and not PAGENAME:find('mittel$') and not PAGENAME:find('pitel$')then
			root_pl = PAGENAME:gsub("t?tel$", "tl")
		else
			root_pl = root
		end
	end

	if not root_sg then
		root_sg = root
	end
	
	-- Create forms
	data.genders = {class:sub(1, 1)} -- extracts e.g. "m" from "m1"
	local definite_singular = {label = "definite singular"}
	local indefinite_plural = {label = "indefinite plural"}
	local definite_plural = {label = "definite plural"}
	
	if class == 'm1' then
		table.insert(definite_singular, root_sg .. 'en')
		table.insert(indefinite_plural, root_pl .. 'er')
		table.insert(definite_plural, root_pl .. 'ene')
	elseif class == 'm2' then
		table.insert(definite_singular, root_sg .. 'en')
		table.insert(indefinite_plural, root_pl .. 'e')
		table.insert(definite_plural, root_pl .. 'ne')
	elseif class == 'm3' then
		root_pl = PAGENAME:gsub("er$", "")
		table.insert(definite_singular, root_sg .. 'en')
		table.insert(indefinite_plural, root_sg .. 'e')
		table.insert(indefinite_plural, root_pl .. 're')
		table.insert(indefinite_plural, root_pl .. 'rer')
		table.insert(definite_plural, root_pl .. 'erne')
		table.insert(definite_plural, root_pl .. 'rene')
	elseif class == 'mu' then
		table.insert(definite_singular, root_sg .. 'en')
	elseif class == 'c' then
		data.genders = {'f', 'm'}
		table.insert(definite_singular, root_sg .. 'a')
		table.insert(definite_singular, root_sg .. 'en')
		table.insert(indefinite_plural, root_pl .. 'er')
		table.insert(definite_plural, root_pl .. 'ene')
	elseif class == 'fmu' or class == 'cu' then
		data.genders = {'f', 'm'}
		table.insert(definite_singular, root_sg .. 'a')
		table.insert(definite_singular, root_sg .. 'en')
	elseif class == 'n1' then
		table.insert(definite_singular, root_sg .. 'et')
		table.insert(indefinite_plural, root_pl)
		table.insert(definite_plural, root_pl .. 'a')
		table.insert(definite_plural, root_pl .. 'ene')
	elseif class == 'n2' then
		table.insert(definite_singular, root_sg .. 'et')
		table.insert(indefinite_plural, root_pl .. 'er')
		table.insert(definite_plural, root_pl .. 'a')
		table.insert(definite_plural, root_pl .. 'ene')
	elseif class == 'n3' then
		table.insert(definite_singular, root_sg .. 'et')
		table.insert(indefinite_plural, PAGENAME)
		table.insert(indefinite_plural, root_pl .. 'er')
		table.insert(definite_plural, root_pl .. 'a')
		table.insert(definite_plural, root_pl .. 'ene')
	elseif class == 'nu' then
		table.insert(definite_singular, root_sg .. 'et')
	end
	
	-- Add inflections
	data.inflections = {definite_singular}
	
	if #indefinite_plural > 0 then
		table.insert(data.inflections, indefinite_plural)
	end
	
	if #definite_plural > 0 then
		table.insert(data.inflections, definite_plural)
	end
 	
 	if gen_dsg then
		table.insert(data.inflections, {label = "genitive definite singular", gen_dsg})
	end
	
	if uncountable then
		table.insert(data.inflections, {label = '[[Appendix:Glossary#uncountable|uncountable]]'})
		table.insert(data.categories, lang:getCanonicalName() .. " uncountable nouns")
	end
	
	return require("Module:headword").full_headword(data)
end

function export.irregular(frame)
	local PAGENAME = mw.title.getCurrentTitle().text
	local args = frame:getParent().args
	local uncountable = false
	
	local data = {lang = lang, pos_category = "nouns", categories = {}, genders = {}, inflections = {}}
	
	-- Gather parameters
	local gen_dsg = args['gen_dsg']; if gen_dsg == "" then gen_dsg = nil end
	
	if args['uncountable'] or args['unc'] then
		uncountable = true
	end
	
	if args[1] == 'c' then
		table.insert(data.genders, 'f')
		table.insert(data.genders, 'm')
	else
		table.insert(data.genders, args[1])
	end
	if args['g2'] then
		table.insert(data.genders, args['g2'])
	end
	if args['g3'] then
		table.insert(data.genders, args['g3'])
	end
	
	-- Insert inflected forms
	local definite_singular = {label = "definite singular"}
	local indefinite_plural = {label = "indefinite plural"}
	local definite_plural = {label = "definite plural"}
	

	table.insert(definite_singular, args[2])
	if args['ds2'] then
		table.insert(definite_singular, args['ds2'])
	end
	table.insert(data.inflections, definite_singular)
	
	if not uncountable then
		table.insert(indefinite_plural, args[3])
		if args['ip2'] then
			table.insert(indefinite_plural, args['ip2'])
		end
		table.insert(data.inflections, indefinite_plural)
		
		table.insert(definite_plural, args[4])
		if args['dp2'] then
			table.insert(definite_plural, args['dp2'])
		end
		table.insert(data.inflections, definite_plural)
	else
		table.insert(data.inflections, {label = '[[Appendix:Glossary#uncoontable|uncoontable]]'})
		table.insert(data.categories, lang:getCanonicalName() .. " uncountable nouns")
	end
	
	if gen_dsg then
		table.insert(data.inflections, {label = "genitive definite singular", gen_dsg})
	end
	
	return require("Module:headword").full_headword(data)
end

return export

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.