Modul:ka-infl-noun

Hej, du er kommet her for at finde betydningen af ordet Modul:ka-infl-noun. I DICTIOUS finder du ikke kun alle ordbogens betydninger af ordet Modul:ka-infl-noun, men du lærer også om dets etymologi, dets karakteristika og hvordan man siger Modul:ka-infl-noun i ental og flertal. Alt, hvad du har brug for at vide om ordet Modul:ka-infl-noun, er her. Definitionen af ordet Modul:ka-infl-noun vil hjælpe dig med at være mere præcis og korrekt, når du taler eller skriver dine tekster. Når du kender definitionen afModul:ka-infl-noun og definitionen af andre ord, beriger du dit ordforråd og får flere og bedre sproglige ressourcer.

Dokumentation for dette modul kan oprettes på Modul:ka-infl-noun/dok

-- Description:
-- Serves ]

-- stripped down version of that of en wikt's

local export = {}

local strutils = require("Module:string utilities")
local declensionTable = require("Modul:ka-infl-noun/declension table")
local postpositionTable = require("Modul:ka-infl-noun/postposition table")

--see what savrtsobi means here ] 
function savrtsobi(s)
	dat = mw.ustring.sub(s, 1, 1)
	gen = mw.ustring.sub(s, 2, 2)
	ins = mw.ustring.sub(s, 3, 3)
	adv = mw.ustring.sub(s, 4, 4)
	return {
		 = dat ~= "-" and "("..dat..")" or "",
		 = gen ~= "-" and "("..gen..")" or "",
		 = ins ~= "-" and "("..ins..")" or "",
		 = adv ~= "-" and "("..adv..")" or "",
	}
end


rules = {}
rules =  {
     = "ი",
     = "მა",
     = "ს",
     = "ის",
     = "ით",
     = "ად",
     = "ო",
}
rules =  {
     = "ი",
     = "მა",
     = "ს",
     = "ის",
     = "ით",
     = "ად",
     = "",
}
rules =  {
     = "",
     = "მ",
     = "ს",
     = "ს",
     = "თ",
     = "დ",
     = "",
}

rules =  {
     = "",
     = "მ",
     = "ს",
     = "ის",
     = "ით",
     = "დ",
     = "ვ",
}
rules =  {
     = "",
     = "მ",
     = "ს",
     = "ს",
     = "თ",
     = "დ",
     = "",
}
rules = rules

rules =  {
     = "",
     = "მ",
     = "ს",
     = "ს",
     = "თ",
     = "დ",
     = "ვ",
}
rules = rules

local modernPluralRule =  {
     = "ი",
     = "მა",
     = "ს",
     = "ის",
     = "ით",
     = "ად",
     = "ო",
}
local archaicPluralRule =  {
     = "ნი",
     = "თ",
     = "თ",
     = "თ",
    --
    --
     = "ნო",
}

forms = {}
postpositions = {}

local definers = {}
local word = nil
local genstem = nil
local term = nil

local noplural = false
local givenname = false
local noarchaic = false
local nosingular = false

local wordType

local DEFINERS = {}

local terms

--Entry point
function export.main(frame)
	local args = frame:getParent().args
	--           debug only
	term = args.term or mw.title.getCurrentTitle().text --PAGENAME
	if mw.text.split(mw.title.getCurrentTitle().prefixedText, ":") == "Template" then  return "" end
	
	terms = mw.text.split(term, " ")
	if #terms == 1 then 
		word = term
	else
		word = terms
		table.remove(terms, #terms)
		definers = terms
	end
	
	local i = 1
	
	if args ~= nil and (args == "" or mw.ustring.find(args, "") ~= nil) then
		genstem = args
		if genstem == "" then genstem = word end
		i = i + 1
	end
	
	local params = {}
	params = false
	params = false
	params = false
	params = false
	
	local newarg = args 
	while newarg ~= nil do
		if newarg == "-" then newarg = "noplural" end
		
		params = true
		newarg = args
		i = i + 1
	end
	
	noplural   = params
	givenname  = params
	noarchaic  = params 
	nosingular = params
	
	analize()
	deriveDefiners()
	fillTable()
	override(args)
	
	--postpositions. this has to happen before makeing links because it depends on square ] brackets
	fillPostpositions()

	makelinks()
	
	forms = ""
	

	return strutils.format(declensionTable.template, forms) .. "" .. strutils.format(postpositionTable.template, postpositions)
end


local STEM_SG
local STEM_SG_ADV
local STEM_SG_GEN_INST
local STEM_PL
local RULE
local SAVRTSOBI
local NOSINGULAR
local NOPLURAL
local NOARCHAIC

function analize()
	--initializing defaults for all endings
	if nosingular then NOSINGULAR = "" end
	if noplural or givenname then NOPLURAL = "" end
	if noarchaic then NOARCHAIC = "" end
	SAVRTSOBI = savrtsobi("აააა")
	--end defaultization xD
	
	local lastLetter = mw.ustring.sub(word, -1)
	if lastLetter == "ი" then
		STEM_SG = mw.ustring.sub(word, 0, -2)
		STEM_SG_GEN_INST = genstem or STEM_SG
		STEM_SG_ADV = genstem or STEM_SG
		
		STEM_PL = genstem or STEM_SG
		
		wordType = "კაცი"
		
		if givenname then
			SAVRTSOBI = savrtsobi("-აა-")
		end
		if genstem ~= nil then
			if #genstem == #word then
				STEM_SG = genstem
				wordType = "ჩაი"
				if not givenname then
					STEM_PL = mw.ustring.sub(word, 0, -2); --rules : "ტრამვაი"
				end
			end
		else
			if givenname then
				wordType = "დავითი"
			end
		end
	elseif lastLetter == "ა" then
		STEM_SG = word
		STEM_SG_GEN_INST = mw.ustring.sub(word, 0, -2)
		STEM_SG_ADV = word
		STEM_PL = mw.ustring.sub(word, 0, -2)
		
		
		wordType = "მთა"
		if givenname then
			STEM_SG_GEN_INST = word
			wordType = "ანა"
			SAVRTSOBI = savrtsobi("-იი-")
		elseif genstem ~= nil then
			STEM_SG_GEN_INST = genstem
			wordType = "ხბო"
			if #genstem ~= #word then
				STEM_SG_ADV = genstem .. "ა"
				STEM_PL = genstem
				wordType = "მთა"
			else
				SAVRTSOBI = savrtsobi("აიია")
			end
		end
	elseif lastLetter == "ე" then
		STEM_SG = word
		STEM_SG_GEN_INST = mw.ustring.sub(word, 0, -2)
		STEM_SG_ADV = word
		STEM_PL = word
		
		
		wordType = "მთა"
		if givenname then
			SAVRTSOBI = savrtsobi("-იი-")
			STEM_SG_GEN_INST = word
			wordType = "ანა"
		end
		if genstem ~= nil then
			STEM_SG_GEN_INST = genstem
			STEM_PL = genstem
			wordType = "ხბო"
			if #genstem ~= #word then
				STEM_SG_ADV = genstem.."ა"
				wordType = "მთა"
				SAVRTSOBI = savrtsobi("აიია")
			end
		end
	elseif lastLetter == "ო" or lastLetter == "უ" then
		STEM_SG = word
		STEM_SG_GEN_INST = word
		STEM_SG_ADV = word
		STEM_PL = word
		
		SAVRTSOBI = savrtsobi("აიია")
		
		if givenname then
			SAVRTSOBI = savrtsobi("-იი-")
		end
		
		wordType = "ხბო"
		if givenname then
			wordType = "დოდო"
		end
	end
	RULE = rules
end



function fillTable()
	forms = term
	
	forms = NOSINGULAR or " .. STEM_SG ..          RULE .. "]]"
	forms = NOSINGULAR or " .. STEM_SG ..          RULE .. "]]"
	forms = NOSINGULAR or " .. STEM_SG ..          RULE .. "]]" .. SAVRTSOBI
	forms = NOSINGULAR or " .. STEM_SG_GEN_INST .. RULE .. "]]" .. SAVRTSOBI
	forms = NOSINGULAR or " .. STEM_SG_GEN_INST .. RULE .. "]]" .. SAVRTSOBI
	forms = NOSINGULAR or " .. STEM_SG_ADV ..      RULE .. "]]" .. SAVRTSOBI
	forms = NOSINGULAR or " .. STEM_SG ..          RULE .. "]]"
	
	forms = NOPLURAL or " .. STEM_PL .. "ებ" .. modernPluralRule .. "]]"
	forms = NOPLURAL or " .. STEM_PL .. "ებ" .. modernPluralRule .. "]]"
	forms = NOPLURAL or " .. STEM_PL .. "ებ" .. modernPluralRule .. "]](ა)"
	forms = NOPLURAL or " .. STEM_PL .. "ებ" .. modernPluralRule .. "]](ა)"
	forms = NOPLURAL or " .. STEM_PL .. "ებ" .. modernPluralRule .. "]](ა)"
	forms = NOPLURAL or " .. STEM_PL .. "ებ" .. modernPluralRule .. "]](ა)"
	forms = NOPLURAL or " .. STEM_PL .. "ებ" .. modernPluralRule .. "]]"
	
	forms = NOPLURAL or NOARCHAIC or " .. STEM_SG .. archaicPluralRule .. "]]"
	forms = NOPLURAL or NOARCHAIC or " .. STEM_SG .. archaicPluralRule .. "]](ა)"
	forms = NOPLURAL or NOARCHAIC or " .. STEM_SG .. archaicPluralRule .. "]](ა)"
	forms = NOPLURAL or NOARCHAIC or " .. STEM_SG .. archaicPluralRule .. "]](ა)"
	--forms
	--forms
	forms = NOPLURAL or NOARCHAIC or " .. STEM_SG .. archaicPluralRule .. "]]"

end

function deriveDefiners()
	local marker = {
		 = "ი",
		 = "მა",
		 = "",
		 = "ი",
		 = "ი",
		 = "",
		 = "ო",

		  = "ი",
		  = "",
		  = "",
		  = "",
		  = "ნო",
	}

	DEFINERS = ""
	DEFINERS = ""
	DEFINERS = ""
	DEFINERS = ""
	DEFINERS = ""
	DEFINERS = ""
	DEFINERS = ""

	DEFINERS = ""
	DEFINERS = ""
	DEFINERS = ""
	DEFINERS = ""
	DEFINERS = ""
	DEFINERS = ""
	DEFINERS = ""

	for index, definer in pairs(definers) do
		local trimLast = mw.ustring.sub(definer, 0, -2);
		local lastLetter = mw.ustring.sub(definer, -1)

		for case, val in pairs(DEFINERS) do
			DEFINERS = DEFINERS .. trimLast .. (lastLetter == "ი" and marker or lastLetter) .. " "
		end
		--DEFINERS = DEFINERS .. " " .. trimLast + (lastLetter == "ი" and marker or lastLetter)
	end
end

function override(args)
	for case, text in pairs(forms) do --WARNING: NOTE, etc.
		forms = mw.ustring.gsub(args or "+", "+", forms)
	end	
end

function makelinks()
	for case, text in pairs(forms) do --WARNING: NOTE, etc.
		forms = mw.ustring.gsub( text, "%%](%(%))", function (captured, sav) -- hyphen is 0 or more non greedy
					return "]" end)
		forms = mw.ustring.gsub( forms, "%-)%]%]", function (captured) 
					return  "]" end)
	end
	
	for postposition, text in pairs(postpositions) do --WARNING: NOTE, etc.
		postpositions = mw.ustring.gsub( text, "%%]", function (captured) -- hyphen is 0 or more non greedy
					return "]" end)
	end
end


--<number of letters to truncate>, <letters to add>
--plurals are OK.
postpRules = {}
postpRules = {
	 = {"dat", 1, "ივით"},
	 = {"dat", 1, "ზე"},
	 = {"dat", 1, "თან"},
	 = {"dat", 1, "ში"},

	 = {"gen", 0, "თვის"},
	 = {"gen", 0, "ებრ"},
	 = {"gen", 0, "კენ"},
	 = {"gen", 0, "გან"},

	 = {"ins", 1, "დან"},
	 = {"ins", 0, "ურთ"},

	 = {"adv", 1, "მდე"}
}
postpRules = {
	 = {"dat", 1, "ივით"},
	 = {"dat", 1, "ზე"},
	 = {"dat", 1, "თან"},
	 = {"dat", 1, "ში"},

	 = {"gen", 0, "თვის"},
	 = {"gen", 0, "ებრ"},
	 = {"gen", 0, "კენ"},
	 = {"gen", 0, "გან"},

	 = {"ins", 1, "დან"},
	 = {"ins", 0, "-"},

	 = {"adv", 1, "მდე"}
}
postpRules = {
	 = {"dat", 1, "ვით"},
	 = {"dat", 1, "ზე"},
	 = {"dat", 0, "თან"},
	 = {"dat", 1, "ში"},

	 = {"gen", 0, "თვის"},
	 = {"gen", 0, "ებრ"},
	 = {"gen", 0, "კენ"},
	 = {"gen", 0, "გან"},

	 = {"ins", 1, "დან"},
	 = {"ins", 0, "ურთ"},

	 = {"adv", 1, "მდე"}
}
postpRules = {
	 = {"dat", 0, "ავით"},
	 = {"dat", 1, "ზე"},
	 = {"dat", 0, "თან"},
	 = {"dat", 1, "ში"},

	 = {"gen", 0, "თვის"},
	 = {"gen", 0, "ებრ"},
	 = {"gen", 0, "კენ"},
	 = {"gen", 0, "გან"},

	 = {"ins", 1, "დან"},
	 = {"ins", 0, "ურთ"},

	 = {"adv", 1, "მდე"}
}
postpRules = {
	 = {"dat", 0, "ავით"},
	 = {"dat", 1, "ზე"},
	 = {"dat", 0, "თან"},
	 = {"dat", 1, "ში"},

	 = {"gen", 0, "თვის"},
	 = {"gen", 0, "ებრ"},
	 = {"gen", 0, "კენ"},
	 = {"gen", 0, "გან"},

	 = {"ins", 1, "დან"},
	 = {"ins", 0, "-"},

	 = {"adv", 1, "მდე"}
}
postpRules = postpRules
postpRules = postpRules
postpRules = postpRules
postpRules = postpRules

function fillPostpositions()
	postpositions = term

	local postpRule = postpRules
	local postpRule_pl = postpRules
	for postSuffix, postGrammar in pairs(postpRule) do
		local case = postGrammar;
		local pattern = string.rep(".", postGrammar) .. "%]%]";
		if case == "dat" or case == "gen" or  case == "ins" or case == "adv" then
			pattern = pattern .. "%(??%)?"
		end
		local res = mw.ustring.gsub(forms, pattern, postGrammar.."]]")

		if postGrammar == "-" then res = "-" end
		postpositions = res
	end

	for postSuffix, postGrammar in pairs(postpRule_pl) do
		local case = postGrammar;
		local pattern = string.rep(".", postGrammar) .. "%]%]";
		if case == "dat" or case == "gen" or  case == "ins" or case == "adv" then
			pattern = pattern .. "%(??%)?"
		end
		local res = mw.ustring.gsub(forms, pattern, postGrammar.."]]")

		if postGrammar == "-" then res = "-" end
		postpositions = res
	end
end

return export