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

Vikisözlük sitesinden
Modül belgelemesi [Düzenle] [Tazele]

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


-- This module contains code for Italian headword templates.
-- Templates covered are it-adj, it-noun and it-proper noun.
-- See [[Module:it-conj]] for Italian conjugation templates.
local export = {}

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

function export.itadj(frame)
	local params = {
		[1] = {},
		[2] = {},
		[3] = {},
		[4] = {},
		[5] = {},
		
		["baş"] = {},
		["sıra"] = {},
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local veri = {dil = lang, soz_kategorisi = "ön adlar", kategoriler = {}, sira_anahtari = args["sıra"], baslar = {args["baş"]}, cinsiyetler = {}, cekimler = {}}
	
	local stem = args[1]
	local end1 = args[2]
	
	if not stem then -- all specified
		veri.baslar = args[2]
		veri.cekimler = {
			{etiket = "dişil tekil", args[3]},
			{etiket = "eril çoğul", args[4]},
			{etiket = "dişil çoğul", args[5]}
		}
	elseif not end1 then -- no ending vowel parameters - generate default
		veri.cekimler = {
			{etiket = "dişil tekil", stem .. "a"},
			{etiket = "eril çoğul", make_plural(stem .. "o","m")},
			{etiket = "dişil çoğul", make_plural(stem .. "a","f")}
		}
	else
		local end2 = args[3] or error("Either 0, 2 or 4 vowel endings should be supplied!")
		local end3 = args[4]
		
		if not end3 then -- 2 ending vowel parameters - m and f are identical
			veri.cekimler = {
				{etiket = "masculine and feminine plural", stem .. end2}
			}
		else -- 4 ending vowel parameters - specify exactly
			local end4 = args[5] or error("Either 0, 2 or 4 vowel endings should be supplied!")
			veri.cekimler = {
				{etiket = "dişil tekil", stem .. end2},
				{etiket = "eril çoğul", stem .. end3},
				{etiket = "dişil çoğul", stem .. end4}
			}
		end
	end
	
	return require("Modül:başlık başı").tam_baslikbasi(veri)
end

function export.itnoun(frame)
	local PAGENAME = mw.title.getCurrentTitle().text
	
	local params = {
		[1] = {list = "c", default = "?"},
		[2] = {list = "ç"},
		
		["baş"] = {list = true},
		["e"] = {list = true},
		["eç"] = {list = true},
		["d"] = {list = true},
		["dç"] = {list = true},
		["sıra"] = {},
	}
	
	local args = require("Modül:parameters").process(frame:getParent().args, params)
	
	local veri = {dil = lang, soz_kategorisi = "adlar", kategoriler = {}, sira_anahtari = args["sıra"], baslar = args["baş"], cinsiyetler = {}, cekimler = {}}
	
	-- Gender
	if args[1][1] == "mf" then
		veri.cinsiyetler = {"m", "f"}
	else
		veri.cinsiyetler = args[1]
	end
	
	if #veri.cinsiyetler == 0 then
		veri.cinsiyetler = {"?"}
	end

	local head = veri.baslar[1] and require("Modül:bağlantılar").kaldir_baglantilari(veri.baslar[1]) or PAGENAME
	-- Plural
	local plural = args[2][1]
	
	if not plural and #args["eç"] == 0 and #args["dç"] == 0 then
		args[2][1] = make_plural(head, veri.cinsiyetler[1])
	end
	
	if plural == "~" then
		table.insert(veri.cekimler, {etiket = "[[Ek:Açıklamalar#sayılamayan|sayılamayan]]"})
		table.insert(veri.kategoriler, "İtalyanca sayılamayan adlar")
	else
		table.insert(veri.kategoriler, "İtalyanca sayılabilen adlar")
	end
	
	if plural == "-" then
		table.insert(veri.cekimler, {etiket = "[[Ek:Açıklamalar#invariable|invariable]]"})
	end
	
	if plural ~= "-" and plural ~= "~" and #args[2] > 0 then
		args[2].etiket = "çoğul"
		table.insert(veri.cekimler, args[2])
	end
	
	-- Other gender
	if #args["d"] > 0 then
		args["d"].etiket = "dişil"
		table.insert(veri.cekimler, args["d"])
	end
	
	if #args["e"] > 0  then
		args["e"].etiket = "eril"
		table.insert(veri.cekimler, args["e"])
	end
	
	if #args["eç"] > 0 then
		args["eç"].etiket = "eril çoğul"
		table.insert(veri.cekimler, args["eç"])
	end

	if #args["dç"] > 0 then
		args["dç"].etiket = "dişil çoğul"
		table.insert(veri.cekimler, args["dç"])
	end

	-- Category
	if head:find('o$') and (veri.cinsiyetler[1] == "d" or veri.cinsiyetler[1] == "f") then
		table.insert(veri.kategoriler, "İtalyanca geçersiz cinsiyetli adlar")
	end
	
	if head:find('a$') and (veri.cinsiyetler[1] == "e" or veri.cinsiyetler[1] == "m") then
		table.insert(veri.kategoriler, "İtalyanca geçersiz cinsiyetli adlar")
	end
	
	return require("Modül:başlık başı").tam_baslikbasi(veri)
end

-- Generate a default plural form, which is correct for most regular nouns
function make_plural(word, gender)
	-- If there are spaces in the term, then we can't reliably form the plural.
	-- Return nothing instead.
	if word:find(" ") then
		return nil
	elseif word:find("io$") then
		word = word:gsub("io$", "i")
	elseif word:find("ologo$") then
		word = word:gsub("o$", "i")
	elseif word:find("[cg]o$") then
		word = word:gsub("o$", "hi")
	elseif word:find("o$") then
		word = word:gsub("o$", "i")
	elseif word:find("[cg]a$") then
		word = word:gsub("a$", (gender == "m" and "hi" or "he"))
	elseif word:find("[cg]ia$") then
		word = word:gsub("ia$", "e")
	elseif word:find("a$") then
		word = word:gsub("a$", (gender == "m" and "i" or "e"))
	elseif word:find("e$") then
		word = word:gsub("e$", "i")
	end
	return word
end

-- Generate a default feminine form
function make_feminine(word, gender)
	if word:find("o$") then
		return word:gsub("o$", "a")
	else
		return word
	end
end

function export.itprop(frame)
	local params = {
		[1] = {list = "g", default = "?"},
		["d"] = {},
		["baş"] = {},
		["e"] = {},
		["sıra"] = {},
	}
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	
	local veri = {dil = lang, soz_kategorisi = "proper nouns", kategoriler = {}, sira_anahtari = args["sıra"], baslar = {args["baş"]}, cinsiyetler = args[1], cekimler = {}}
	
	for i, g in ipairs(veri.cinsiyetler) do
		if g == "p" then
			veri.cinsiyetler[i] = "?-p"
		end
		
		if g == "m-p" or g == "f-p" or g == "?-p" or g == "p" then
			table.insert(veri.cekimler, {etiket = "[[Ek:Açıklamalar#sadece çoğul|sadece çoğul]]"})
			table.insert(veri.kategoriler, lang:getirAsilAd() .. " pluralia tantum")
			break
		end
	end
	if args["e"] then
		table.insert(veri.cekimler, {etiket = "eril", args["e"]})
	end
	if args["d"] then
		table.insert(veri.cekimler, {etiket = "dişil", args["d"]})
	end
	
	return require("Modül:başlık başı").tam_baslikbasi(veri)
end

return export

-- For Vim, so we get 4-space tabs
-- vim: set ts=4 sw=4 noet: