Module:nn-decl

From Wiktionary, the free dictionary
Jump to navigation Jump to search


local p = {}
 
function p.main(frame)
    local PAGENAME = mw.title.getCurrentTitle().text
    args = frame:getParent().args
    
	if args[1] then
        gender = args[1]
    else
        gender = '?'
	end
	
	if args[2] then
        stem = args[2]
    else
        stem = '?'
	end

	if args[3] then
		wordroot = args[3]
	end

	if args[4] then
        form = args[4]
    else
        form = ''
	end	

	if args[5] then
        decl = args[5]
    else
        decl = ''
	end	
	
	-- Landsmål
	if form == 'aasen' then
		
		-- Feminine
		if gender == 'f' then
			if stem == 'o' then
				nasi = wordroot .. ''
				gsi = wordroot .. 'ar-'
				nasd = wordroot .. 'i'
				dsd = wordroot .. 'enne'
				napi = wordroot .. 'er'
				gpi = wordroot .. 'e-'
				napd = wordroot .. 'erna'
				dpd = wordroot .. 'om'
			elseif stem == 'jo' then
				nasi = wordroot .. ''
				gsi = wordroot .. 'ar-'
				nasd = wordroot .. 'i'
				dsd = wordroot .. 'enne'
				napi = wordroot .. 'ar'
				gpi = wordroot .. 'e-'
				napd = wordroot .. 'arne'
				dpd = wordroot .. 'om'
			elseif stem == 'jo-j' then
				nasi = wordroot .. ''
				gsi = wordroot .. 'jar-'
				nasd = wordroot .. 'i'
				dsd = wordroot .. 'enne'
				napi = wordroot .. 'jar'
				gpi = wordroot .. 'je-'
				napd = wordroot .. 'jarne'
				dpd = wordroot .. 'jom'
			elseif stem == 'on' then
				nasi = wordroot .. 'a'
				gsi = wordroot .. 'e-'
				nasd = wordroot .. 'a'
				dsd = wordroot .. 'onne'
				napi = wordroot .. 'or'
				gpi = ''
				napd = wordroot .. 'orna'
				dpd = wordroot .. 'om'
			end
			
		-- Masculine
		elseif gender == 'm' then
			if stem == 'a' then
				nasi = wordroot .. ''
				gsi = wordroot .. 's-'
				nasd = wordroot .. 'en'
				dsd = wordroot .. 'e'
				napi = wordroot .. 'ar'
				gpi = wordroot .. 'e-'
				napd = wordroot .. 'arne'
				dpd = wordroot .. 'om'
			elseif stem == 'an' then
				nasi = wordroot .. 'e'
				nasd = wordroot .. 'en'
				dsd = wordroot .. 'a'
				napi = wordroot .. 'ar'
				napd = wordroot .. 'arne'
				dpd = wordroot .. 'om'
			elseif stem == 'i' then
				nasi = wordroot .. ''
				gsi = ''
				nasd = wordroot .. 'en'
				dsd = wordroot .. 'e'
				napi = wordroot .. 'er'
				gpi = wordroot .. 'e-'
				napd = wordroot .. 'erne'
				dpd = wordroot .. 'om'
			end
			
		-- Neuter
		elseif gender == 'n' then
			if stem == 'a' then
				nasi = wordroot .. ''
				gsi = wordroot .. 's-'
				nasd = wordroot .. 'et'
				dsd = wordroot .. 'e'
				napi = wordroot .. ''
				gpi = wordroot .. 'e-'
				napd = wordroot .. 'i'
				dpd = wordroot .. 'om'
			elseif stem == 'an' then
				nasi = wordroot .. 'a'
				gsi = wordroot .. 'e-'
				nasd = wordroot .. 'at'
				dsd = wordroot .. 'a'
				napi = wordroot .. 'o'
				gpi = wordroot .. 'ne-'
				napd = wordroot .. 'o'
				dpd = wordroot .. 'om'
			elseif stem == 'ija' then
				nasi = wordroot .. 'e'
				gsi = wordroot .. 'es-'
				nasd = wordroot .. 'et'
				dsd = wordroot .. 'e'
				napi = wordroot .. 'e'
				gpi = wordroot .. 'e-'
				napd = wordroot .. 'i'
				dpd = wordroot .. 'om'
			elseif stem == 'ija-j' then
				nasi = wordroot .. 'e'
				gsi = wordroot .. 'es-'
				nasd = wordroot .. 'et'
				dsd = wordroot .. 'e'
				napi = wordroot .. 'e'
				gpi = wordroot .. 'je-'
				napd = wordroot .. 'i'
				dpd = wordroot .. 'jom'
			end
		end
		
------------------------------------------------

	-- Official standard (2012-)
	else
		
		-- Femninine
		if gender == 'f' then
			if stem == 'o' then
				nasi = wordroot .. ''
				gsi = wordroot .. 'e-'
				nasd = wordroot .. 'a'
				napi = wordroot .. 'er'
				gpi = wordroot .. 'e-'
				napd = wordroot .. 'ene'
			elseif stem == 'on' then
				nasi = wordroot .. 'e'
				gsi = wordroot .. 'e-'
				nasd = wordroot .. 'a'
				napi = wordroot .. 'er'
				gpi = ''
				napd = wordroot .. 'ene'
			end
			
		-- Masculine
		elseif gender == 'm' then
			if stem == 'a' then
				nasi = wordroot .. ''
				gsi = wordroot .. 's-'
				nasd = wordroot .. 'en'
				napi = wordroot .. 'ar'
				gpi = wordroot .. 'e-'
				napd = wordroot .. 'ane'
			elseif stem == 'an' then
				nasi = wordroot .. 'e'
				gsi = wordroot .. 'e-'
				nasd = wordroot .. 'en'
				napi = wordroot .. 'ar'
				gpi = wordroot .. 'e-'
				napd = wordroot .. 'ane'
			elseif stem == 'i' then
				nasi = wordroot .. ''
				gsi = wordroot .. 'e-'
				nasd = wordroot .. 'en'
				napi = wordroot .. 'er'
				gpi = wordroot .. 'e-'
				napd = wordroot .. 'ene'
			end
		end
	end
	
	if decl == 'nasi' then
		decl = nasi
	elseif decl == 'gsi' then
		decl = gsi
	elseif decl == 'nasd' then
		decl = nasd
	elseif decl == 'dsd' then
		decl = dsd
	elseif decl == 'napi' then
		decl = napi
	elseif decl == 'gpi' then
		decl = gpi
	elseif decl == 'napd' then
		decl = napd
	elseif decl == 'dpd' then
		decl = dpd
	elseif form == 'aasen' then
		decl = 'Landsmål'
	elseif form == 'setesdal' then
		decl = 'Setesdal'
	else 
		decl = ''
	end

    template = decl
    return template
end

function p.stem(frame)
    local PAGENAME = mw.title.getCurrentTitle().text
    args = frame:getParent().args
    
	if args[1] then
        stem = args[1]
	end
	if stem == 'f' then
		stem = 'feminine'
	elseif stem == 'm' then
		stem = 'masculine'
	elseif stem == 'n' then
		stem = 'neuter'
	elseif stem == 'o' then
		stem = 'ō'
	elseif stem == 'jo' then
		stem = 'jō'
	elseif stem == 'jo-j' then
		stem = 'jō'
	elseif stem == 'on' then
		stem = 'ōn'
	elseif stem == 'a' then
		stem = 'a'
	elseif stem == 'an' then
		stem = 'an'
	elseif stem == 'i' then
		stem = 'i'
	elseif stem == 'u' then
		stem = 'u'
	elseif stem == 'jo' then
		stem = 'jō'
	elseif stem == 'jo-j' then
		stem = 'jō'
	elseif stem == 'ijo' then
		stem = 'ijō'
	elseif stem == 'ija' then
		stem = 'ija'
	elseif stem == 'ija-j' then
		stem = 'ija'
	end
	
    template = stem
    return template
end
 
return p