Module:sac-decl

Hello, you have come here looking for the meaning of the word Module:sac-decl. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:sac-decl, but we will also tell you about its etymology, its characteristics and you will know how to say Module:sac-decl in singular and plural. Everything you need to know about the word Module:sac-decl you have here. The definition of the word Module:sac-decl will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:sac-decl, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local export = {}

local args = {}
local m_links = require('Module:links')
local lang = require('Module:languages').getByCode('sac')

local gender = 'an'

numbers = {
	'1',
	'1+2',
	'2',
	'3',
	'X'
}
cases = {
	'P', --proximate
	'O', --obviative
	'V', --vocative
	'L', --local
}

possessor_prefixes = {
	 = 'ne',
	 = 'ke',
	 = 'ke',
	 = 'o',
	 = 'o',
}
number_suffixes_sg = {
	 = '',
	 = '',
	 = '',
	 = 'inaw',
}
number_suffixes_pl = {
	 = 'enân',
	 = 'enân',
	 = 'wâw',
	 = 'wâw',
}
casesg_an = {
	 = 'a',   
	 = 'ani',
	 = 'e',
	 = 'eki',
}
casepl_an = {
	 = 'aki',
	 = 'ahi',
	 = 'etike',
}
casesg_inan = {
	 = 'i',
	 = 'eki',
}
casepl_inan = {
	 = 'ani',
}

casesg = casesg_an
casepl = casepl_an

function export.show(frame)
	PAGENAME = mw.title.getCurrentTitle().text
	args = require("Module:parameters").process(
		frame:getParent().args,
		{
			 = {
				default = mw.ustring.gsub(PAGENAME, "(.*)$", "%1")
			},
			 = {
				type = 'boolean'
			},
			 = {},
			 = {
				default = 'i',
			},
		}
	)
	local stem = args..'@' -- so we don't contract something that shouldn't be contracted
	if frame.args == 'inan' then
		gender = 'inan'
		casesg = casesg_inan
		casepl = casepl_inan
	end
	
	local forms = generate_forms(stem)
	
	forms = modify_forms(forms)

	return make_table(forms)
end

function generate_forms(stem)
	local forms = {}
	--unpossessed forms
	for _, case in ipairs(cases) do
		if casesg then
			forms = stem..casesg
		end
		
		if casepl then
			forms = stem..casepl
		end
	end

	if mw.ustring.match(stem,'^') then
		stem = 't'..stem
	end
	
	--possessed forms
	local em = (args and '' or 'em')
	for _, possessor in ipairs(numbers) do
		for _, case in ipairs(cases) do
			
			--singular possessive
			if number_suffixes_sg then
				if casesg then
					forms = possessor_prefixes..stem..em..number_suffixes_sg..casesg
				end
				
				if casepl then
					forms = possessor_prefixes..stem..em..number_suffixes_sg..casepl
				end
			end
		
			--plural possessive
			if number_suffixes_pl then
				if casesg then
					forms = possessor_prefixes..stem..em..number_suffixes_pl..casesg
				end
				
				if casepl then
					forms = possessor_prefixes..stem..em..number_suffixes_pl..casepl
				end
			end
		end
	end
	return forms
end

cons = '()'

function modify_forms(forms)
	for k,v in pairs(forms) do
		forms = mw.ustring.gsub(forms,'R()','sh%1')
		forms = mw.ustring.gsub(forms,'R','n')
		
		forms = mw.ustring.gsub(forms,cons..'w@e'..cons,'%1o%2') -- we > o / C_C
		forms = mw.ustring.gsub(forms,cons..'w@wâ','%1o@wâ') -- 2pl/3pl, by analogy with the above
		
		if args ~= 'wa' then
			forms = mw.ustring.gsub(forms,'()w@a'..cons,'%1ô%2') -- wa > ô / C_C exc. after /k/
			if args == 'ô' then -- wa > ô even after /k/
				forms = mw.ustring.gsub(forms,'kw@a'..cons,'kô%1')
			end
		end
		forms = mw.ustring.gsub(forms,cons..'y@e'..cons,'%1'..args..'%2')
		
		forms = mw.ustring.gsub(forms,cons..'y@wâ','%1'..args..'@wâ') -- 2pl/3pl, by analogy with the above
	
		forms = mw.ustring.gsub(forms,cons..'y@a'..cons,'%1ê%2')
		
		forms = mw.ustring.gsub(forms,'w@inaw','w@enaw')
		
		forms = mw.ustring.gsub(forms,'w@e','â') -- there is a better way to do this probably but I can't be bothered
		forms = mw.ustring.gsub(forms,'w@e','ê')
		forms = mw.ustring.gsub(forms,'w@e','î')
		forms = mw.ustring.gsub(forms,'w@e','ô')
		forms = mw.ustring.gsub(forms,'w@e','û')
		
		forms = mw.ustring.gsub(forms,'w@w','âw')
		forms = mw.ustring.gsub(forms,'w@w','êw')
		forms = mw.ustring.gsub(forms,'w@w','îw')
		forms = mw.ustring.gsub(forms,'w@w','ôw')
		forms = mw.ustring.gsub(forms,'w@w','ûw')
		
		forms = mw.ustring.gsub(forms,'ay@e','â')
		forms = mw.ustring.gsub(forms,'iy@e','î')
		forms = mw.ustring.gsub(forms,'iy@i','i')

		forms = mw.ustring.gsub(forms,'ay@w','âw')
		forms = mw.ustring.gsub(forms,'iy@w','îw')

		forms = mw.ustring.gsub(forms,'@','')
	end
	return forms
end

function make_table(forms)
	return [=[<div class="NavFrame">
<div class="NavHead">Inflection of ]=] .. forms .. [=[</div>
<div class="NavContent">
{| style="width:100%; background:#F0F0F0; color:#000000; text-align:center;" class="inflection-table" cellspacing="1"
|-
! colspan="2" style="background:#87cefa" | Unpossessed
! colspan="2" style="background:#87cefa" | Singular Noun
! colspan="2" style="background:#87cefa" | Plural Noun
]=] .. make_rows_unpossessed(forms) .. [=[
|-
! colspan="2" rowspan="2" style="background:#87cefa" | Possessed
! colspan="2" style="background:#87cefa" | Singular Noun
! colspan="2" style="background:#87cefa" | Plural Noun
|-
! style="background:#87cefa" | Singular Possessive
! style="background:#87cefa" | Plural Possessive
! style="background:#87cefa" | Singular Possessive
! style="background:#87cefa" | Plural Possessive
]=] .. (gender == 'inan' and make_rows_possessed_inan(forms) or make_rows_possessed(forms)) .. [=[
|}</div></div>]=] .. make_categories()
end

possessor_names = {
	 = 'First person',
	 = 'First and second person',
	 = 'Second person',
	 = 'Third person',
	 = 'Indefinite',
}
case_names = {
	 = 'Proximate',
	 = 'Obviative',
	 = 'Vocative',
	 = 'Local',
}

function make_rows_unpossessed(forms)
	local s = ''
	local cases_local = (gender == 'inan' and {'P','L'} or cases)
	for _, case in ipairs(cases_local) do
		s = s .. '|-\n! colspan="2" style="background:#87cefa" | '..case_names..'\n'
		s = s .. link_form(forms,true)
		s = s .. link_form(forms,true)
	end
	return s
end

function make_rows_possessed(forms)
	local s = ''
	for _, possessor in ipairs(numbers) do
		s = s .. '|-\n! rowspan="' .. (possessor == '3' and '3' or '4') .. '" style="background:#87cefa" | '..possessor_names..'\n'
		for i, case in ipairs(cases) do
			if (possessor ~= '3') or (case ~= 'P') then --3rd person has no proximate. wish Lua had a continue statement
				if case ~= (possessor == '3' and 'O' or 'P') then s = s .. '|-\n' end
				s = s .. '! style="background:#87cefa" | '..case_names..'\n'
				s = s .. link_form(forms)
				s = s .. link_form(forms)
				s = s .. link_form(forms)
				s = s .. link_form(forms)
			end
		end
	end
	return s
end

function make_rows_possessed_inan(forms)
	local s = ''
	for _, possessor in ipairs(numbers) do
		s = s .. '|-\n! rowspan="2" style="background:#87cefa" | '..possessor_names..'\n'
		for i, case in ipairs({'P','L'}) do
			if case ~= 'P' then s = s .. '|-\n' end
			s = s .. '! style="background:#87cefa" | '..case_names..'\n'
			s = s .. link_form(forms)
			s = s .. link_form(forms)
			s = s .. link_form(forms)
			s = s .. link_form(forms)
		end
	end
	return s
end

function link_form(term, colspan)
	if term then
		if colspan then
			return '| colspan="2" | '..m_links.full_link({lang=lang, term=term})..'\n'
		else
			return '| '..m_links.full_link({lang=lang, term=term})..'\n'
		end
	else
		if colspan then
			return '| style="background:#c0c0c0" colspan="2" | &nbsp;\n'
		else
			return '| style="background:#c0c0c0" | &nbsp;\n'
		end
	end
end

function make_categories()
	if gender == 'inan' then
		return ']'
	else
		return ']'
	end
end

return export