Modül:ja-söyleniş

Merhaba, buraya Modül:ja-söyleniş kelimesinin anlamını aramaya geldiniz. DICTIOUS'da Modül:ja-söyleniş kelimesinin tüm sözlük anlamlarını bulmakla kalmayacak, aynı zamanda etimolojisini, özelliklerini ve Modül:ja-söyleniş kelimesinin tekil ve çoğul olarak nasıl söylendiğini de öğreneceksiniz. Modül:ja-söyleniş kelimesi hakkında bilmeniz gereken her şey burada. Modül:ja-söyleniş kelimesinin tanımı, konuşurken veya metinlerinizi yazarken daha kesin ve doğru olmanıza yardımcı olacaktır. XXX'in ve diğer kelimelerin tanımını bilmek, kelime dağarcığınızı zenginleştirir ve size daha fazla ve daha iyi dilsel kaynaklar sağlar.
Modül belgelemesi


local export = {}
local gsub = mw.ustring.gsub
local match = mw.ustring.match
local sub = mw.ustring.sub
local len = mw.ustring.len

local lang = require("Modül:diller").getirKodaGore("ja")
local m_ja = require("Modül:ja")
local m_accent = require("Modül:aksan belirtici")
-- ayrıca ]

local PAGENAME = mw.title.getCurrentTitle().text

local function quote(text)
	return  "“" .. text .. "”"
end

local ref_template_name_data = {
	 = 'KYK:Daijirin',
	 = 'KYK:NHK Hatsuon',
	 = 'KYK:Shinmeikai2',
	 = 'KYK:Shinmeikai5',
	 = 'KYK:Zenkoku Akusento Jiten',
	 = 'KYK:Kenkyusha JEL Pocket',
}

local function generate_ref_tag(ref_name)
	local ref_template_name = ref_template_name_data
	
	if not ref_template_name then
		-- ]
		return nil
	end

	local ref_tag = mw.getCurrentFrame():extensionTag{
		name = 'ref',
		args = { name = ref_name },
		content = '{{' .. ref_template_name .. '}}',
	}

	return ref_tag
end

local function add_acc_refs(text)
	local output = {}

	if mw.ustring.match(text, 'ref') then
		table.insert(output, mw.getCurrentFrame():preprocess(text))
	else
		for ref_name in mw.text.gsplit(text, '%s*,%s*') do
			table.insert(output, generate_ref_tag(ref_name))
		end
	end

	return table.concat(output)
end

function export.goster(frame)
	local params = {
		 = {default = PAGENAME, list = true},
		
		 = {alias_of = "yomi"},
		 = {},
		
		 = {list = true},
		 = {list = true},
		 = {list = true},
		 = {list = true},
		
		 = {alias_of = "aksan", list = true},
		 = {alias_of = "aksan_yer", list = true},	-- using "aksan=_loc" (etc.) doesn't work
		 = {alias_of = "aksan_kaynak", list = true},
		 = {alias_of = "aksan_not", list = true},
		
		 = {},
		 = {},
		 = {},
		
		 = {},
		
		 = {alias_of = "ses"},
		 = {}
	}
	
	local args = require("Modül:parameters").process(frame:getParent().args, params)
	
	local yomi, au = args.yomi, args.ses
	local dev = args or args
	local dev2 = args
	local maxindex = table.getn(args)
	local result = ""
	local text
	
	local yomi_types = {
		o = "on", on = "on",
		go = "goon", goon = "goon",
		ko = "kanon", kan = "kanon", kanon = "kanon",
		to = "toon", toon = "toon",
		ky = "kanyoon", kanyo = "kanyoon", kanyoon = "kanyoon",
		k = "kun", kun = "kun",
		j = "ju", ju = "ju",
		y = "yu", yu = "yu",
		i = "düzensiz", irr = "düzensiz", irreg = "düzensiz", irregular = "düzensiz", d = "düzensiz",  = "düzensiz"
	}
	
	local yomi_text = {
		on = "]",
		goon = "]: ]",
		kanon = "]: ]",
		toon = "]: ]",
		kanyoon = "]",
		kun = "]",
		ju = "]",
		yu = "]",
		 = require("Modül:belirtici").bicimlendir_belirtici("Düzensiz okunuş")
	}
	
	-- Deals with the yomi
	if yomi then
		if yomi_types then
			yomi = yomi_types
		else
			error(quote(yomi) .. " yomi tipi tanınmıyor. Şablon:ja-söyleniş/belgeleme sayfasındaki tanınan tiplere bakın")
		end
		
		local kanji = mw.ustring.gsub(PAGENAME, "+", "")
		
		if mw.ustring.len(kanji) ~= 2 and (yomi == "ju" or yomi == "yu") then
		end
		
		result = "* " .. yomi_text
	end
	
	-- Deals with the accents
	local a, al, ar, an = args.aksan, args.aksan_yer, args.aksan_kaynak, args.aksan_not
	for i, position in ipairs(a) do
		text = args
		if yomi then result = result .. "\n**" else result = result .. "\n*"
		end
		if not al then
			al = "]"
		end
		result = result .. m_accent.goster({al}) .. " "
		
		result = result .. export.accent(text, position, dev, dev2)
		if ar then
			result = result .. add_acc_refs(ar)
		end
		result = result .. (an and (" " .. an) or "")
	end
	
	-- Deals with the IPA
	if not ipayok then
		local m_IPA = require("Modül:IPA")
		for i, text in ipairs(args) do
			local sortkey = m_ja.jsort(text)
			result = result .. (yomi and "\n**" or "\n*")
			result = result .. m_IPA.bicim_IPA_tam(lang, {{ soyl = "" }}, nil, nil, sortkey)
		end
	end
	
	-- Deals with the audio
	if au then
		sortkey = m_ja.jsort(args)
		if yomi then result = result .. "\n**" else result = result .. "\n*"
		end
		result = result .. ' <table class="audiotable" style="vertical-align: top; display:inline-block; list-style:none;line-height: 1em;"><tr><td class="unicode audiolink">Ses</td><td class="audiofile">]</td><td class="audiometa" style="font-size: 80%;">(])</td></tr></table>]'
	end
	
	return result
end

function export.ipa(text, dev, dev2)
	if type(text) == "table" then
		text, dev, dev2 = text.args, text.args, text.args end
	dev = dev or ""
	dev2 = dev2 or ""
	
	if dev2 ~= "" then error('Lütfen bür2 parametresini kaldırın ve bunu bür parametresine çevirin \"bür=' .. dev .. ',' .. dev2 .. '"') end
	
	local position_kana = {}
	local position_mora = {}
	
	for i=1,mw.ustring.len(text) do
		if sub(text,i,i) ~= ' ' then
			table.insert(position_kana, i)
			if not mw.ustring.match(sub(text,i,i), "") then
				table.insert(position_mora, i)
			end
		end
	end
	
	if dev ~= "" then
		for position in mw.text.gsplit(dev,",") do
			position = tonumber(position)
			if #position_mora == position then
				text = text .. "̥"
			else
				position = position_mora
				text = sub(text, 1, position-1) .. "̥" .. sub(text, position, -1)
			end
			for i=position+1,table.getn(position_mora) do
				position_mora = position_mora + 1
			end
		end
	end
	
	text = m_ja.kana_to_romaji(text, { keep_period = true })
	
	text = gsub(text, "&#39;", "ʔ")
	
	text = gsub(text, "?", {
		 = "p̚p",  = "t̚ch",  = "k̚k",  = "b̚b̥",  = "d̚j",
		 = "d̚d̥",  = "g̚g̊",  = "d̚z",  = "t̚t",  = "t̚ts",
		 = "r̚r",  = "ɕː" })
	
	text = gsub(text, "ei", "ē")
	text = gsub(text, "", {
		 = "aː",  = "eː",  = "iː",  = "oː",  = "uː", 
		 = "ɸ",  = "b",  = "d͡ʑ",  = "ɾ",  = "j",  = "d͡z" })
	
	text = gsub(text, "", {
		 = "ɕ", 
		 = "t͡ɕ", 
		 = "t͡s" })
	
	text = gsub(text, "()d͡()", "%1%2")
	text = gsub(text, "(?)i", "%1ʲi")
	text = gsub(text, "(?)j", "%1ʲ")
	text = gsub(text, "nʲ", "ɲ̟")
	
	text = gsub(text, "()(ː?)n()", "%1̃%2n%3")
	for i, args in pairs{
			{ "(ː?)n$", "̃%1ɴ" },
			{ "n( ?)()", "m%1%2" },
			{ "n( ?)(.͡)", "ɲ̟%1%2" },
			{ "n( ?)ɲ̟", "ɲ̟%1ɲ̟" },
			{ "n( ?)()(ʲ?)", "ŋ%1%3%2%3" },
			{ "n( ?)()", "ɰ̃%1%2" },
			{ "n'", "ɰ̃" },
			{ "n ()", "ɰ̃ %1" },
		} do
		
		text = gsub(text, args, args)
	end
	
	text = gsub(text, "h", {
		 = "çi",  = "ç", 
		 = "ɸu" })
	
	text = gsub(text, "h()", "%1%1")
	text = gsub(text, "()%1", "%1ː")
	text = gsub(text, "ːʲ", "ʲː")
	text = gsub(text, "̚(.?)ʲ", "̚ʲ%1ʲ")
	text = gsub(text, "", {
		 = "a̠", 
		 = "e̞", 
		 = "o̞", 
		 = "ɯ̟ᵝ", 
		 = "ɰᵝ"})
	
	text = gsub(text, "()ɯ̟", "%1ɨ")
	
	text = gsub(text, "ᵝ̥", "̥ᵝ")
	text = gsub(text, "ᵝ̃", "̃ᵝ")
	text = gsub(text, "̠", "̥̃˗")
	text = gsub(text, "̞", "̥̃˕")
	text = gsub(text, "̟", "̥̃˖")
	text = gsub(text, "()̥", "%1̊")
	text = gsub(text, "%.", "")
	text = gsub(text, "'", ".")
	text = gsub(text, "g", "ɡ")
	
	return text
end

function export.rise_and_fall(word, rftype)
	word = gsub(word, "()()", "%1.%2")
	word = gsub(word, "()()", "%1.%2")
	word = m_ja.kana_to_romaji(word)

	if rftype == "rise" then
		word = gsub(word, ".", {
			 = "á",  = "é",  = "í",  = "ó",  = "ú", 
			 = "áá",  = "éé",  = "íí",  = "óó",  = "úú" })
	
		word = gsub(gsub(word, "n()", "ń%1"), "n$", "ń")
		
	elseif rftype == "fall" then
		word = gsub(word, ".", {
			 = "à",  = "è",  = "ì",  = "ò",  = "ù", 
			 = "àà",  = "èè",  = "ìì",  = "òò",  = "ùù" })
		
		word = gsub(gsub(word, "n()", "ǹ%1"), "n$", "ǹ")
		
	else
		return error("Type not recognised.")
	end
	
	return word
end

-- ] and ] rely on the output format of this function
function export.accent(text, class, dev, dev2)
	if(type(text)) == "table" then text, class, dev, dev2 = text.args, text.args, text.args, text.args end
	text = gsub(text, "()", "%1ー")
	text = gsub(text, "()", "%1ー")
	text = gsub(text, "%.", "")
	if dev == "" then dev = false end
	if dev2 == "" then dev2 = false end
	
	local down_first = "<span style=\"border-top:1px solid black;position:relative;padding:1px;\">"
	local down_last = "<span style=\"position:absolute;top:0;bottom:67%;right:0%;border-right:1px solid black;\">&#8203;</span></span>"
	local high_first = "<span style=\"border-top:1px solid black\">"
	local start = "<span lang=\"ja\" class=\"Jpan\">"
	local romaji_start = " <span class=\"Latn\"><samp>["
	local romaji_last = "]</samp></span> "
	local last = "</span>"
	
	local position_kana = {}       --position of each kana (ぁ counted), text without space
	local position_mora = {}       --position of each mora (ぁ not counted), text without space
	local position_mora_space = {} --position of each mora (ぁ not counted), text with space
	
	for i=1,mw.ustring.len(text) do
		if not mw.ustring.match(sub(text,i,i), "") then
			local extra = mw.ustring.len(mw.ustring.match(sub(text,i+1), "^*"))
			table.insert(position_mora_space, i+extra)
		end
	end
	local space_removed = mw.ustring.gsub(text," ","")
	for i=1,mw.ustring.len(space_removed) do
		table.insert(position_kana, i)
		if not mw.ustring.match(sub(space_removed,i,i), "") then
			local extra = mw.ustring.len(mw.ustring.match(sub(space_removed,i+1), "^*"))
			table.insert(position_mora, i+extra)
		end
	end
	
	if match(class, "^$") then
		acc_type, acc_number = "h", 0
		
	elseif match(class, "^$") then
		acc_type, acc_number = "a", 1
	
	elseif match(class, "^o$") then
		acc_type = "o"
	end
	
	if match(class, "^+$") and not match(class,"^$") then
		class = gsub(class, "", "")
		acc_number = tonumber(class)
		
		morae_count = len(gsub(text, "", ""))
			
		if morae_count == acc_number then
			acc_type = "o"
		elseif morae_count < acc_number then
			return error(("Bürünbirimcik sayısı (%d) aşağı yöndeki bürünbirimcik pozisyonundan (%d) daha küçük.")
				:format(morae_count, acc_number))
		else
			acc_type = "n"
		end
	elseif not acc_number then
		acc_number = class
	end
	
	local start_index = 1
	while match(sub(text, start_index+1, start_index+1), "") do
		start_index = start_index + 1
	end
	
	local kanas = {}
	local single_mora
	for i=1,mw.ustring.len(text) do
		if not mw.ustring.match(sub(text,i,i), "") then
			single_mora = gsub(sub(text, i, -1), "^(.*).*", "%1")
			table.insert(kanas, single_mora)
		end
	end
	
	local function kana_devoice(text)
		return '<span style="border:1px dotted gray; border-radius:50%;">' .. text .. "</span>"
	end
	
	if dev then
		for position in mw.text.gsplit(dev, ",") do
			position = tonumber(position)
			kanas = kana_devoice(kanas)
		end
	end
	
	romaji_text = gsub(text, "()ー", "%1お")
	romaji_text = gsub(romaji_text, "()ー", "%1え")
	romaji_text = gsub(romaji_text, "()ー", "%1う")
	romaji_text = gsub(romaji_text, "()ー", "%1い")
	romaji_text = gsub(romaji_text, "()ー", "%1あ")
	
	local romajis = mw.text.split(romaji_text, "")
	
	local function count_nspaces(text, index)
		local i, sample, nspaces = 0, "", 0
		while len(sample) < index do
			i = i + 1
			sample, nspaces = gsub(sub(text, 1, i), " ", "")
		end
		return nspaces
	end
	
	local function romaji_devoice(text)
		return text .. "̥"
	end
	
	if dev then
		for position in mw.text.gsplit(dev,",") do
			position = position_mora_space
			romajis = romaji_devoice(romajis)
		end
	end
	
	if acc_type == "n" then
		r_start_index = start_index + count_nspaces(romaji_text, start_index)
		local r_index = position_mora_space
		local k_index = acc_number
		
		r_parts = {
			 = table.concat(romajis, "", 1, r_start_index),
			 = table.concat(romajis, "", r_start_index + 1, r_index),
			 = table.concat(romajis, "", r_index + 1, #romajis)
		}
				
		k_parts = {
			 = table.concat(kanas, "", 1, 1),
			 = table.concat(kanas, "", 2, k_index),
			 = table.concat(kanas, "", k_index + 1, #kanas)
		}
		
		result = start .. 
			k_parts .. 
			down_first .. 
			k_parts .. 
			down_last .. 
			k_parts .. 
			last .. 
			romaji_start .. 
			export.rise_and_fall(r_parts, "fall") .. 
			export.rise_and_fall(r_parts, "rise") .. 
			"ꜜ" .. 
			export.rise_and_fall(r_parts, "fall") .. 
			romaji_last .. 
			"(] – )"
		
	else
		r_start_index = start_index + count_nspaces(romaji_text, start_index)
		r_parts = {
			 = table.concat(romajis, "", 1, r_start_index),
			 = table.concat(romajis, "", r_start_index + 1, #romajis)
		}
		
		k_parts = {
			 = table.concat(kanas, "", 1, 1),
			 = table.concat(kanas, "", 2, #kanas)
		}
		
		if acc_type == "h" then
			result = start .. 
				k_parts .. 
				high_first .. 
				k_parts .. 
				last .. 
				last .. 
				romaji_start .. 
				export.rise_and_fall(r_parts, "fall") .. 
				export.rise_and_fall(r_parts, "rise") .. 
				romaji_last .. 
				"(] – )"
				
 		elseif acc_type == "a" then
			result = start .. 
				down_first .. 
				k_parts .. 
				down_last .. 
				k_parts .. 
				last .. 
				romaji_start .. 
				export.rise_and_fall(r_parts, "rise") .. 
				"ꜜ" .. 
				export.rise_and_fall(r_parts, "fall") .. 
				romaji_last .. 
				"(] – )"
				
		elseif acc_type == "o" then
			result = start .. 
				k_parts .. 
				down_first .. 
				k_parts .. 
				down_last .. 
				last .. 
				romaji_start .. 
				export.rise_and_fall(r_parts, "fall") .. 
				export.rise_and_fall(r_parts, "rise") .. 
				"ꜜ" .. 
				romaji_last .. 
				"(] – )"
				
		else
			return error("Aksan tipi tanınmıyor.")
		end
		
	end
	
	result = gsub(result, "(.)̥", "<del>%1</del>")
	
	return result
end

return export