Modül:en-başlıkbaşı

Modül belgelemesi [Düzenle] [Tazele]

Bu Lua modülü, şu şablonların çıktısını vermektedir:


local export = {}
local pos_functions = {}

local lang = require("Modül:diller").getirKodaGore("en")

-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
	PAGENAME = mw.title.getCurrentTitle().text
	
	local poscat = frame.args[1] or error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")
	
	local params = {
		["baş"] = {list = true, default = ""},
		["suff"] = {type = "boolean"},
	}
	
	if pos_functions[poscat] then
		for key, val in pairs(pos_functions[poscat].params) do
			params[key] = val
		end
	end
	
	local args = require("Modül:parameters").process(frame:getParent().args, params)
	local veri = {dil = lang, soz_kategorisi = poscat, kategoriler = {}, baslar = args["baş"], cekimler = {}}
	
	if args["suff"] then
		veri.soz_kategorisi = "suffixes"
		
		if poscat == "adjectives" then
			table.insert(veri.kategoriler, lang:getirAsilAd() .. " ön ad yapan ekler")
		elseif poscat == "adverbs" then
			table.insert(veri.kategoriler, lang:getirAsilAd() .. " belirteç yapan ekler")
		elseif poscat == "nouns" then
			table.insert(veri.kategoriler, lang:getirAsilAd() .. " ad yapan ekler")
		elseif poscat == "verbs" then
			table.insert(veri.kategoriler, lang:getirAsilAd() .. " eylem yapan ekler")
		else
			error("No category exists for suffixes forming " .. poscat .. ".")
		end
	end
	
	if pos_functions[poscat] then
		pos_functions[poscat].func(args, veri)
	end
	
	local pagename = mw.title.getCurrentTitle().text
	if pagename:find("[Qq][^Uu]") or pagename:find("[Qq]$") then
		table.insert(veri.kategoriler, lang:getirAsilAd() .. " ardından U gelmeyen Q harfi içeren sözcükler")
	end
	
	return require("Modül:başlık başı").tam_baslikbasi(veri)
end

-- This function does the common work between adjectives and adverbs
function make_comparatives(params, veri)
	local comp_parts = {etiket = "karşılaştırma", accel = "comparative-form-of"}
	local sup_parts = {etiket = "üstünlük", accel = "superlative-form-of"}
	
	if #params == 0 then
		table.insert(params, {"more"})
	end
	
	-- To form the stem, replace -(e)y with -i and remove a final -e.
	local stem = PAGENAME:gsub("([^aeiou])e?y$", "%1i"):gsub("e$", "")
	
	-- Go over each parameter given and create a comparative and superlative form
	for i, val in ipairs(params) do
		local comp = val[1]
		local sup = val[2]
		
		if comp == "more" and PAGENAME ~= "many" and PAGENAME ~= "much" then
			table.insert(comp_parts, "[[more]] " .. PAGENAME)
			table.insert(sup_parts, "[[most]] " .. PAGENAME)
		elseif comp == "further" and PAGENAME ~= "far" then
			table.insert(comp_parts, "[[further]] " .. PAGENAME)
			table.insert(sup_parts, "[[furthest]] " .. PAGENAME)
		elseif comp == "er" then
			table.insert(comp_parts, stem .. "er")
			table.insert(sup_parts, stem .. "est")
		elseif comp == "-" or sup == "-" then
			-- Allowing '-' makes it more flexible to not have some forms
			if comp ~= "-" then
				table.insert(comp_parts, comp)
			end
			if sup ~= "-" then
				table.insert(sup_parts, sup)
			end
		else
			-- If the full comparative was given, but no superlative, then
			-- create it by replacing the ending -er with -est.
			if not sup then
				if comp:find("er$") then
					sup = comp:gsub("er$", "est")
				else
					error("The superlative of \"" .. comp .. "\" cannot be generated automatically. Please provide it with the \"sup" .. (i == 1 and "" or i) .. "=\" parameter.")
				end
			end
			
			table.insert(comp_parts, comp)
			table.insert(sup_parts, sup)
		end
	end
	
	table.insert(veri.cekimler, comp_parts)
	table.insert(veri.cekimler, sup_parts)
end

pos_functions["ön adlar"] = {
	params = {
		[1] = {list = true, allow_holes = true},
		["sup"] = {list = true, allow_holes = true},
		},
	func = function(args, veri)
		local shift = 0
		local is_not_comparable = 0
		local is_comparative_only = 0
		
		-- If the first parameter is ?, then don't show anything, just return.
		if args[1][1] == "?" then
			return
		-- If the first parameter is -, then move all parameters up one position.
		elseif args[1][1] == "-" then
			shift = 1
			is_not_comparable = 1
		-- If the only argument is +, then remember this and clear parameters
		elseif args[1][1] == "+" and args[1].maxindex == 1 then
			shift = 1
			is_comparative_only = 1
		end
		
		-- Gather all the comparative and superlative parameters.
		local params = {}
		
		for i = 1, args[1].maxindex - shift do
			local comp = args[1][i + shift]
			local sup = args["sup"][i]
			
			if comp or sup then
				table.insert(params, {comp, sup})
			end
		end
		
		if shift == 1 then
			-- If the first parameter is "-" but there are no parameters,
			-- then show "not comparable" only and return.
			-- If there are parameters, then show "not generally comparable"
			-- before the forms.
			if #params == 0 then
				if is_not_comparable == 1 then
					table.insert(veri.cekimler, {etiket = "karşılaştırılamaz"})
					table.insert(veri.kategoriler, lang:getirAsilAd() .. " karşılaştırılamayan ön adlar")
					return
				end
				if is_comparative_only == 1 then
					table.insert(veri.cekimler, {etiket = "[[Ek:Açıklamalar#comparable|comparative]] form only"})
					table.insert(veri.kategoriler, lang:getirAsilAd() .. " kıyaslanabilir ön adlar")
					return
				end
			else
				table.insert(veri.cekimler, {etiket = "not generally [[Ek:Açıklamalar#comparable|comparable]]"})
			end
		end
		
		-- Process the parameters
		make_comparatives(params, veri)
	end
}

pos_functions["belirteçler"] = {
	params = {
		[1] = {list = true, allow_holes = true},
		["sup"] = {list = true, allow_holes = true},
		},
	func = function(args, veri)
		local shift = 0
		
		-- If the first parameter is ?, then don't show anything, just return.
		if args[1][1] == "?" then
			return
		-- If the first parameter is -, then move all parameters up one position.
		elseif args[1][1] == "-" then
			shift = 1
		end
		
		-- Gather all the comparative and superlative parameters.
		local params = {}
		
		for i = 1, args[1].maxindex - shift do
			local comp = args[1][i + shift]
			local sup = args["sup"][i]
			
			if comp or sup then
				table.insert(params, {comp, sup})
			end
		end
		
		if shift == 1 then
			-- If the first parameter is "-" but there are no parameters,
			-- then show "not comparable" only and return. If there are parameters,
			-- then show "not generally comparable" before the forms.
			if #params == 0 then
				table.insert(veri.cekimler, {etiket = "karşılaştırılamaz"})
				table.insert(veri.kategoriler, lang:getirAsilAd() .. " kıyaslanamayan belirteçler")
				return
			else
				table.insert(veri.cekimler, {etiket = "not generally [[Ek:Açıklamalar#comparable|comparable]]"})
			end
		end
		
		-- Process the parameters
		make_comparatives(params, veri)
	end
}

pos_functions["adlar"] = {
	params = {
		[1] = {list = true, allow_holes = true},
		
		-- TODO: This should really be a list parameter too...
		["plqual"] = {},
		["pl2qual"] = {},
		["pl3qual"] = {},
		["pl4qual"] = {},
		["pl5qual"] = {},
		},
	func = function(args, veri)
		-- Gather all the plural parameters from the numbered parameters.
		local plurals = {}
		
		for i = 1, args[1].maxindex do
			local pl = args[1][i]
			
			if pl then
				local qual = args["pl" .. (i == 1 and "" or i) .. "qual"]
				
				if qual then
					table.insert(plurals, {sozcuk = pl, belirticiler = {qual}})
				else
					table.insert(plurals, pl)
				end
			end
		end
		
		-- Decide what to do next...
		local mode = nil
		
		if plurals[1] == "?" or plurals[1] == "!" or plurals[1] == "-" or plurals[1] == "~" then
			mode = plurals[1]
			table.remove(plurals, 1)  -- Remove the mode parameter
		end
		
		-- Plural is unknown
		if mode == "?" then
			table.insert(veri.kategoriler, lang:getirAsilAd() .. " çoğulu bilinmeyen veya belli olmayan adlar")
			return
		-- Plural is not attested
		elseif mode == "!" then
			table.insert(veri.cekimler, {etiket = "plural not attested"})
			table.insert(veri.kategoriler, lang:getirAsilAd() .. " doğrulanmamış çoğulu olan adlar")
			return
		-- Uncountable noun; may occasionally have a plural
		elseif mode == "-" then
			table.insert(veri.kategoriler, lang:getirAsilAd() .. " sayılamayan adlar")
			
			-- If plural forms were given explicitly, then show "usually"
			if #plurals > 0 then
				table.insert(veri.cekimler, {etiket = "genellikle sayılamayan"})
				table.insert(veri.kategoriler, lang:getirAsilAd() .. " sayılabilen adlar")
			else
				table.insert(veri.cekimler, {etiket = "[[Ek:Açıklamalar#sayılamayan|sayılamayan]]"})
			end
		-- Mixed countable/uncountable noun, always has a plural
		elseif mode == "~" then
			table.insert(veri.cekimler, {etiket = "[[Ek:Açıklamalar#sayılabilen|sayılabilen]] ve [[Ek:Açıklamalar#sayılamayan|sayılamayan]]"})
			table.insert(veri.kategoriler, lang:getirAsilAd() .. " sayılamayan adlar")
			table.insert(veri.kategoriler, lang:getirAsilAd() .. " sayılabilen adlar")
			
			-- If no plural was given, add a default one now
			if #plurals == 0 then
				plurals = {"s"}
			end
		-- The default, always has a plural
		else
			table.insert(veri.kategoriler, lang:getirAsilAd() .. " sayılabilen adlar")
			
			-- If no plural was given, add a default one now
			if #plurals == 0 then
				plurals = {"s"}
			end
			if plural and not mw.title.new(plural).exists then
				table.insert(categories, "English nouns with missing plurals")
			end
		end
		
		-- If there are no plurals to show, return now
		if #plurals == 0 then
			return
		end
		
		-- There are plural forms to show, so show them
		local pl_parts = {etiket = "çoğulu", accel = "plural-form-of"}
		
		local stem = PAGENAME
		
		for i, pl in ipairs(plurals) do
			if pl == "s" then
				table.insert(pl_parts, stem .. "s")
			elseif pl == "es" then
				table.insert(pl_parts, stem .. "es")
			else
				table.insert(pl_parts, pl)
			end
		end
		
		table.insert(veri.cekimler, pl_parts)
	end
}

pos_functions["özel adlar"] = {
	params = {
		[1] = {list = true},
		},
	func = function(args, veri)
		local plurals = args[1]
		
		-- Decide what to do next...
		local mode = nil
		
		if plurals[1] == "?" or plurals[1] == "!" or plurals[1] == "-" or plurals[1] == "~" then
			mode = plurals[1]
			table.remove(plurals, 1)  -- Remove the mode parameter
		end
		
		-- Plural is unknown
		if mode == "?" then
			table.insert(veri.kategoriler, lang:getirAsilAd() .. " çoğulu bilinmeyen veya belli olmayan özel adlar")
			return
		-- Plural is not attested
		elseif mode == "!" then
			table.insert(veri.cekimler, {etiket = "plural not attested"})
			table.insert(veri.kategoriler, lang:getirAsilAd() .. " doğrulanmamış çoğulu olan özel adlar")
			return
		-- Uncountable noun; may occasionally have a plural
		elseif mode == "-" then
			-- If plural forms were given explicitly, then show "usually"
			if #plurals > 0 then
				table.insert(veri.cekimler, {etiket = "usually [[Ek:Açıklamalar#sayılamayan|sayılamayan]]"})
				table.insert(veri.kategoriler, lang:getirAsilAd() .. " sayılabilen özel adlar")
			else
				table.insert(veri.cekimler, {etiket = "[[Ek:Açıklamalar#sayılamayan|sayılamayan]]"})
			end
		-- Mixed countable/uncountable noun, always has a plural
		elseif mode == "~" then
			table.insert(veri.cekimler, {etiket = "[[Ek:Açıklamalar#sayılabilen|sayılabilen]] ve [[Ek:Açıklamalar#sayılamayan|sayılamayan]]"})
			table.insert(veri.kategoriler, lang:getirAsilAd() .. " sayılabilen özel adlar")
			
			-- If no plural was given, add a default one now
			if #plurals == 0 then
				plurals = {"s"}
			end
		elseif #plurals > 0 then
			table.insert(veri.kategoriler, lang:getirAsilAd() .. " sayılabilen özel adlar")
		end
		
		-- If there are no plurals to show, return now
		if #plurals == 0 then
			return
		end
		
		-- There are plural forms to show, so show them
		local pl_parts = {etiket = "çoğulu", accel = "proper-noun-plural-form-of"}
		
		local stem = PAGENAME
		
		for i, pl in ipairs(plurals) do
			if pl == "s" then
				table.insert(pl_parts, stem .. "s")
			elseif pl == "es" then
				table.insert(pl_parts, stem .. "es")
			else
				table.insert(pl_parts, pl)
			end
	
		end
		
		table.insert(veri.cekimler, pl_parts)
	end
}

pos_functions["eylemler"] = {
	params = {
		[1] = {list = "pres_3sg", allow_holes = true},
		
		["pres_3sg_qual"] = {},
		["pres_3sg2_qual"] = {},
		["pres_3sg3_qual"] = {},
		["pres_3sg4_qual"] = {},
		["pres_3sg5_qual"] = {},
		
		[2] = {list = "pres_ptc", allow_holes = true},
		
		["pres_ptc_qual"] = {},
		["pres_ptc2_qual"] = {},
		["pres_ptc3_qual"] = {},
		["pres_ptc4_qual"] = {},
		["pres_ptc5_qual"] = {},
		
		[3] = {list = "past", allow_holes = true},
		
		["past_qual"] = {},
		["past2_qual"] = {},
		["past3_qual"] = {},
		["past4_qual"] = {},
		["past5_qual"] = {},
		
		[4] = {list = "past_ptc", allow_holes = true},
		
		["past_ptc_qual"] = {},
		["past_ptc2_qual"] = {},
		["past_ptc3_qual"] = {},
		["past_ptc4_qual"] = {},
		["past_ptc5_qual"] = {},
		},
	func = function(args, veri)
		-- Get parameters
		local par1 = args[1][1]
		local par2 = args[2][1]
		local par3 = args[3][1]
		local par4 = args[4][1]
		
		local pres_3sg_forms = {etiket = "üçüncü tekil kişi geniş zaman", accel = "third-person-singular-form-of"}
		local pres_ptc_forms = {etiket = "şimdiki zaman", accel = "present-participle-form-of"}
		local past_forms = {etiket = "basit geçmiş zaman", accel = "simple-past-form-of"}
		local pres_3sg_form = par1 or PAGENAME .. "s"
		local pres_ptc_form = par2 or PAGENAME .. "ing"
		local past_form = par3 or PAGENAME .. "ed"
		
		if par1 and not par2 and not par3 then
			-- This is the "new" format, which uses only the first parameter.
			if par1 == "es" then
				pres_3sg_form = PAGENAME .. "es"
				pres_ptc_form = PAGENAME .. "ing"
				past_form = PAGENAME .. "ed"
			elseif par1 == "ies" then
				if not mw.ustring.find(PAGENAME, "y$") then
					error("The first parameter is \"ies\" but the verb does not end in -y.")
				end
				
				local stem = mw.ustring.gsub(PAGENAME, "y$", "")
				pres_3sg_form = stem .. "ies"
				pres_ptc_form = stem .. "ying"
				past_form = stem .. "ied"
			elseif par1 == "d" then
				pres_3sg_form = PAGENAME .. "s"
				pres_ptc_form = PAGENAME .. "ing"
				past_form = PAGENAME .. "d"
			else
				pres_3sg_form = PAGENAME .. "s"
				pres_ptc_form = par1 .. "ing"
				past_form = par1 .. "ed"
			end
		else
			-- This is the "legacy" format, using the second and third parameters as well.
			-- It is included here for backwards compatibility and to ease the transition.
			if par3 then
				if par3 == "es" then
					pres_3sg_form = par1 .. par2 .. "es"
					pres_ptc_form = par1 .. par2 .. "ing"
					past_form = par1 .. par2 .. "ed"
				elseif par3 == "ing" then
					pres_3sg_form = PAGENAME .. "s"
					pres_ptc_form = par1 .. par2 .. "ing"
					
					if par2 == "y" then
						past_form = PAGENAME .. "d"
					else
						past_form = par1 .. par2 .. "ed"
					end
				elseif par3 == "ed" then
					
					if par2 == "i" then
						pres_3sg_form = par1 .. par2 .. "es"
						pres_ptc_form = PAGENAME .. "ing"
					else
						pres_3sg_form = PAGENAME .. "s"
						pres_ptc_form = par1 .. par2 .. "ing"
					end
					
					past_form = par1 .. par2 .. "ed"
				elseif par3 == "d" then
					pres_3sg_form = PAGENAME .. "s"
					pres_ptc_form = par1 .. par2 .. "ing"
					past_form = par1 .. par2 .. "d"
				end
			else
				if par2 == "es" then
					pres_3sg_form = par1 .. "es"
					pres_ptc_form = par1 .. "ing"
					past_form = par1 .. "ed"
				elseif par2 == "ies" then
					
					
					pres_3sg_form = par1 .. "ies"
					pres_ptc_form = par1 .. "ying"
					past_form = par1 .. "ied"
				elseif par2 == "ing" then
					pres_3sg_form = PAGENAME .. "s"
					pres_ptc_form = par1 .. "ing"
					past_form = par1 .. "ed"
				elseif par2 == "ed" then
					pres_3sg_form = PAGENAME .. "s"
					pres_ptc_form = par1 .. "ing"
					past_form = par1 .. "ed"
				elseif par2 == "d" then
					
					pres_3sg_form = PAGENAME .. "s"
					pres_ptc_form = par1 .. "ing"
					past_form = par1 .. "d"
				end
			end
		end
		
		local pres_3sg_qual = args["pres_3sg_qual"]
		local pres_ptc_qual = args["pres_ptc_qual"]
		local past_qual = args["past_qual"]
		
		table.insert(pres_ptc_forms, {sozcuk = pres_ptc_form, belirticiler = {pres_ptc_qual}})
		table.insert(pres_3sg_forms, {sozcuk = pres_3sg_form, belirticiler = {pres_3sg_qual}})
		table.insert(past_forms, {sozcuk = past_form, belirticiler = {past_qual}})
		
		-- Present 3rd singular
		for i = 2, args[1].maxindex do
			local form = args[1][i]
			local qual = args["pres_3sg" .. i .. "_qual"]
			
			if form then
				table.insert(pres_3sg_forms, {sozcuk = form, belirticiler = {qual}})
			end
		end
		
		-- Present participle
		for i = 2, args[2].maxindex do
			local form = args[2][i]
			local qual = args["pres_ptc" .. i .. "_qual"]
			
			if form then
				table.insert(pres_ptc_forms, {sozcuk = form, belirticiler = {qual}})
			end
		end
		
		-- Past
		for i = 2, args[3].maxindex do
			local form = args[3][i]
			local qual = args["past" .. i .. "_qual"]
			
			if form then
				table.insert(past_forms, {sozcuk = form, belirticiler = {qual}})
			end
		end
		
		-- Past participle
		local past_ptc_forms = {etiket = "geçmiş ortacı", accel = "past-participle-form-of"}
		
		if par4 then
			local qual = args["past_ptc_qual"]; if qual == "" then qual = nil end
			table.insert(past_ptc_forms, {sozcuk = par4, belirticiler = {qual}})
			
			for i = 2, args[4].maxindex do
				local form = args[4][i]
				local qual = args["past_ptc" .. i .. "_qual"]
				
				if form then
					table.insert(past_ptc_forms, {sozcuk = form, belirticiler = {qual}})
				end
			end
		end
		
		-- Are the past forms identical to the past participle forms?
		local identical = true
		
		if #past_forms ~= #past_ptc_forms then
			identical = false
		else
			for key, val in ipairs(past_forms) do
				if past_ptc_forms[key].sozcuk ~= val.sozcuk or past_ptc_forms[key].qual ~= val.qual then
					identical = false
					break
				end
			end
		end
		
		-- Insert the forms
		table.insert(veri.cekimler, pres_3sg_forms)
		table.insert(veri.cekimler, pres_ptc_forms)
		
		if #past_ptc_forms == 0 or identical then
			past_forms.etiket = "geçmiş zaman ve yakın geçmiş zaman"
			past_forms.accel = "simple-past-and-participle-form-of"
			table.insert(veri.cekimler, past_forms)
		else
			table.insert(veri.cekimler, past_forms)
			table.insert(veri.cekimler, past_ptc_forms)
		end
	end
}

return export