Modül:hak-söyleniş

Merhaba, buraya Modül:hak-söyleniş kelimesinin anlamını aramaya geldiniz. DICTIOUS'da Modül:hak-söyleniş kelimesinin tüm sözlük anlamlarını bulmakla kalmayacak, aynı zamanda etimolojisini, özelliklerini ve Modül:hak-söyleniş kelimesinin tekil ve çoğul olarak nasıl söylendiğini de öğreneceksiniz. Modül:hak-söyleniş kelimesi hakkında bilmeniz gereken her şey burada. Modül:hak-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 sub = mw.ustring.sub
local match = mw.ustring.match
local find = mw.ustring.find
local len = mw.ustring.len

function export.rom_display(text,convtype)
	if type(text) == 'table' then text,convtype = text.args,(text.args or '') end
	local display = ''
	local show = {  = '',  = '' }
	local decomp = mw.text.split(gsub(text,'/',' / '),';',true)
	local TableTools = require('Modül:table')
	for i = 1,#decomp,1 do
		if match(decomp,'pfs') then
			decomp = gsub(decomp,'pfs=','')
			local pfs_readings = {  = {},  = {} }
			local hrs_readings = {  = {},  = {} }
			local hpy_readings = {  = {},  = {} }
			local ipa_readings = {  = {},  = {} }
			local function display_format(style)
				local label = {  = 'Kuzey ',  = 'Güney ',  = '' }
				local city = {
						= ']',
						= ']',
						= '] ve ]'
					}
				local text = string.format("\n** <small>(''], incl. %s'')</small>", label, city)
				text = text .. "\n*** <small>'']''</small>: <span style=\"font-family: Consolas, monospace;\">" .. table.concat(pfs_readings, ' / ') .. '</span>'
				text = text .. "\n*** <small>'']''</small>: <span style=\"font-family: Consolas, monospace;\">" .. table.concat(hrs_readings, ' / ') .. '</span>'
				text = text .. "\n*** <small>'']''</small>: <span style=\"font-family: Consolas, monospace;\">" .. table.concat(hpy_readings, ' / ') .. '</span>'
				local ipa = '\n*** <small>Sinolojik ]'
				local span = '</small>: <span class="IPA">/'
				text = text .. ipa
				if style == 'ns' then
					local north = table.concat(ipa_readings, '/, /')
					local south = table.concat(ipa_readings, '/, /')
					if north == south then
						text = text .. span .. north .. '/</span>'
					else
						text = text .. " (''Kuzey, incl. " .. city .. "'')" .. span .. north .. "/</span>"
						text = text .. ipa .. " (''Güney, incl. " .. city .. "'')" .. span .. south .. "/</span>"
					end
				else
					text = text .. span .. table.concat(ipa_readings, '/, /') .. '/</span>'
				end
				return text
			end
			local function southern(text)
				local function convert(a, b, c)
					local e_a = {  = 'a',  = 'â',  = 'á',  = 'à' }
					return a .. e_a .. c
				end
				text = gsub(text, '()()(̍?)', convert)
				text = gsub(text, '(gi)()(̍?)', convert)
				text = gsub(text, '(h?i)()(̍?)', convert)
				text = gsub(text, '^(i)()(̍?)', convert)
				text = gsub(text, '(i)()(̍?)', convert)
				return text
			end
			local function add(style, reading)
				pfs_readings + 1] = reading
				hrs_readings + 1] = export.hrs(reading, style)
				hpy_readings + 1] = export.pfs_to_hpy(reading)
				ipa_readings + 1] = export.ipa(reading, style)
			end
			
			local ns = true
			for _, reading in ipairs(mw.text.split(decomp, ' / ')) do
				if match(reading,':') then
					local pair = mw.text.split(reading, ':')
					if pair == 'ns' then
						add('n', pair)
						add('s', pair)
					else
						ns = false
						add(pair, pair)
					end
				elseif match(reading,'') or reading ~= southern(reading) then
					ns = false
					add('n', reading)
					add('s', southern(reading))
				else
					add('n', reading)
					add('s', reading)
				end
			end
		
			if convtype == '' then
				if ns then 
					display = display .. display_format('ns')
				else
					if #pfs_readings ~= 0 then display = display .. display_format('n') end
					if #pfs_readings ~= 0 then display = display .. display_format('s') end
				end
			else
				for i, reading in ipairs(pfs_readings) do
					pfs_readings + 1] = pfs_readings
				end
				show = table.concat(TableTools.removeDuplicates(pfs_readings), ' / ')
			end
		end
		if match(decomp,'gd') then
			if convtype == '' then
				display = display .. "\n** <small>('']'')</small>"
				display = display .. "\n*** <small>'']''</small>: <span style=\"font-family: Consolas, monospace;\">" .. string.gsub(string.gsub(decomp,'gd=',''),'()','<sup>%1</sup>') .. '</span>'
				display = display .. '\n*** <small>Sinolojik ]</small>: <span class="IPA">/' .. export.gd_to_ipa(decomp) .. "/</span>"
			else
				show = gsub(gsub(decomp, 'gd=', ''), '()', '<sup>%1</sup>')
			end
		end
	end
	if convtype ~= '' then
		local pfs = " <small>(''], ]'')</small>: <span style=\"font-family: Consolas, monospace;\">" .. show .. '</span>'
		local gd = " <small>(''], ]'')</small>: <span style=\"font-family: Consolas, monospace;\">" .. show .. '</span>'
		if show ~= '' and show ~= '' then
			display = display .. '\n*:' .. pfs .. '\n*:' .. gd
		elseif show ~= '' then
			display = display .. pfs
		elseif show ~= '' then
			display = display .. gd
		end
	end
	return display
end

local function find_tone(text)
	text = mw.ustring.toNFD(text)
	if find(text, '̂') then
		return 1
	elseif find(text, '̀') then
		return 2
	elseif find(text, '́') then
		return 3
	elseif find(text, '̍') then
		return 6
	elseif find(text, '$') then 
		return 5
	else
		return 4
	end
end

function export.ipa(text, dialect)
	local syllables, initial, final, tone, tone_conv = {}, {}, {}, {}, {}
	local ipa = {}
	if type(text) == 'table' then text = text.args end
	text = gsub(gsub(gsub(mw.ustring.lower(text), '%.', ''), '%s+$', ''), '%s+', '-')
	syllables = mw.text.split(text, "-")
	for i, syllable in ipairs(syllables) do
		syllable = gsub(syllable, ",", "")
		syllable = gsub(syllable,'o̍',{='ua̍',='ue̍'})
		syllable = gsub(syllable,'',{='ua',='uá',='uà',='uâ',='uā',='ue',='ué',='uè',='uê',='uē'})
		
		local palatal = false
		initial = match(syllable, '^??h?')
		final = sub(syllable, len(initial) + 1, -1)
		if find(final, '^') then
			palatal = true
		end
		local function add_palatal(text, add_or_not)
			local palatal_initial = {
				 = true,
				 = true,
				 = true,
				 = true
			}
			if add_or_not and palatal_initial then
				return text .. 'i'
			else
				return text
			end
		end
		local initial_ipa = {
			 = 'ɲ',
			 = 'ŋ',
			 = 'pʰ',
			 = 'tʰ',
			 = 'kʰ',
			 = 't͡s',
			 = 't͡ɕ',
			 = 't͡sʰ',
			 = 't͡ɕʰ',
			 = 'ɕ',
			 = 'i'
		}
		initial = initial_ipa, palatal)] or initial
		tone = find_tone(final)
		local final_conv = {
			 = 'a',  = 'e',  = 'i',  = 'o',  = 'u',  = '',
			 = 'a',  = 'e',  = 'i',  = 'o',  = 'u',  = '',
			 = 'a',  = 'e',  = 'i',  = 'o',  = 'u',  = '',
			 = 'n',  = 'n',
			 = '',
			 = 'ɨ',
		}
		final = gsub(final, '', final_conv)
		if initial == 'i' then
			final = (find(final, '^i?$') and '' or 'i') .. final
			initial = dialect == 's' and '(j)' or ''
		end
		final = gsub(final, '()$', '%1̚')
		final = gsub(final, 'ng$', 'ŋ')
		final = final == 'ŋ' and 'ŋ̍' or final
		final = gsub(final, 'er$', 'ə')
		final = gsub(final, '()()(?)', function(first, second, third)
				if third ~= '' then
					first = first .. '̯'
					third = third .. '̯'
				elseif first == 'i' or first == 'u' then
					first = first .. '̯'
				elseif second == 'i' or second == 'u' then
					second = second .. '̯'
				end
			return first .. second .. third end)
	end
	for i, syllable in ipairs(syllables) do
		local tone_ipa = {
			 = '²⁴',
			 = '¹¹',
			 = '³¹',
			 = '⁵⁵',
			 = '²',
			 = '⁵',
		}
		tone_conv = tone_ipa]
		if (tone == 1 and find(tostring(tone), '') and not find(syllable, ",")) or (syllable == 'é' and dialect == 'n' and find(mw.title.getCurrentTitle().text, '仔') and find(text, '-é') and find(tostring(tone), '')) then
			tone_conv = tone_conv .. '⁻¹¹'
		end
		
		ipa = initial .. final .. tone_conv
	end
	return gsub(table.concat(ipa, " "), ",", "")
end

function export.hrs(text, dialect)
	if type(text) == 'table' then text = text.args end
	local syllables = mw.text.split(gsub(mw.ustring.lower(text), ' ', '-'), "-")
	for i, syllable in ipairs(syllables) do
		-- check for commas
		local comma = ''
		if find(syllable, ',') then
			comma = ','
			syllable = sub(syllable, 1, -2)
		end
		-- change consonants
		syllable = gsub(syllable,'',{='b',='d',='g',=dialect == 's' and '(r)i' or 'i'})
		syllable = gsub(syllable,'h',{='p',='t',='k',='z'})
		syllable = gsub(syllable,'zh','c')
		local palatal = {='j',='q',='x',=''}
		syllable = gsub(syllable,'()()', function(a,b) return palatal..b end)
		
		-- find tones
		local marks = {  = '´',  = 'ˇ',  = '`',  = '`' }
		local tone = marks or ''
		
		-- remove tone marks and fix vowels
		syllable = gsub(syllable, 'ṳ', 'ii')
		syllable = gsub(mw.ustring.toNFD(syllable), '', '')
		syllable = gsub(syllable, 'o()', 'u%1')
		
		-- add new tone marks
		syllables = syllable .. tone .. comma
	end
	return table.concat(syllables, " ")
end

function export.pfs_to_hpy(text)
	if type(text) == 'table' then text = text.args end
	local syllables = mw.text.split(gsub(mw.ustring.lower(text), ' ', '-'), "-")
	for i, syllable in ipairs(syllables) do
		if syllable == '...' then
			syllables = syllable
		else
			-- check for commas
			local comma = ''
			if find(syllable, ',') then
				comma = ','
				syllable = sub(syllable, 1, -2)
			end
			-- change consonants
			syllable = gsub(syllable,'',{='b',='d',='g'})
			syllable = gsub(syllable,'h',{='p',='t',='k',='z'})
			syllable = gsub(syllable,'zh','c')
			local palatal = {='j',='q',='x'}
			syllable = gsub(syllable,'()()', function(a,b) return palatal..b end)
			
			-- find tones
			local tone = find_tone(syllable)
			
			-- remove tone marks and fix vowels
			syllable = gsub(syllable, 'ṳ', 'i')
			syllable = gsub(mw.ustring.toNFD(syllable), '', '')
			syllable = gsub(syllable, 'o()', 'u%1')
			syllable = syllable == 'yu' and 'yiu' or syllable
			syllable = gsub(syllable, '()e()', '%1a%2')
			
			-- put everything together
			syllables = syllable .. '<sup>' .. tone .. '</sup>' .. comma
		end
	end
	return table.concat(syllables, " ")
end

function export.gd_to_ipa(text)
	local initial_conv = {
		 = "p",  = "pʰ",  = "m",  = "f",  = "ʋ",
		 = "t",  = "tʰ",  = "n",  = "l", 
		 = "k",  = "kʰ",  = "ŋ",  = "h",
		 = "t͡s",  = "t͡sʰ",  = "s",
		 = "t͡ɕ",  = "t͡ɕʰ",  = "ɕ",
		 = "",
	}
	local final_conv = {
		 = "z̩",  = "i",  = "u",
		 = "a",  = "ia",  = "ua",
		 = "e",  = "ie",  = "ue",
		 = "o",  = "io",  = "uo",
		 = "m̩",  = "n̩",
		 = "aɪ",  = "iaɪ",  = "uaɪ",
		 = "oɪ",
		 = "uɪ",  = "iuɪ",
		 = "au",  = "iau",
		 = "eu",
		 = "iu",
		 = "əm",  = "im",
		 = "am",  = "iam",
		 = "ɛm",
		 = "ən",  = "in",
		 = "an",  = "ian",  = "uan",
		 = "ɛn",  = "iɛn",  = "uɛn",
		 = "ɔn",  = "iɔn",  = "uɔn",
		 = "un",  = "iun",
		 = "aŋ",  = "iaŋ",  = "uaŋ",
		 = "ɔŋ",  = "iɔŋ",  = "uɔŋ",
		 = "ʊŋ",  = "iʊŋ",
		 = "əp̚",  = "ip̚",
		 = "ap̚",  = "iap̚",
		 = "ɛp̚",
		 = "ət̚",  = "it̚",
		 = "at̚",  = "iat̚",  = "uat̚",
		 = "ɛt̚",  = "iɛt̚",  = "uɛt̚",
		 = "ɔt̚",
		 = "ut̚",  = "iut̚",
		 = "ak̚",  = "iak̚",  = "uak̚",
		 = "ɔk̚",  = "iɔk̚",  = "uɔk̚",
		 = "ʊk̚",  = "iʊk̚",
	}
	local tone_conv = {
		 = "⁴⁴",  = "¹¹",
		 = "³¹",
		 = "⁵³",
		 = "¹",  = "⁵",
		 = "⁴⁴⁻³⁵",
		 = "⁵³⁻⁵⁵",
	}
	local palatal = {
		 = 'c',
		 = 'cʰ',
		 = 'ɲ',
		 = 'ç',
	}
	
	if type(text) == 'table' then text = text.args end
	local words = mw.text.split(text, " / ")
	local result = {}
	for _, word in ipairs(words) do
		word = gsub(gsub(gsub(word, 'gd=', ''), '', ''), '%s+$', '')
		local syllables = mw.text.split(word, '%s+')
		local initial, final, tone, ipa = {}, {}, {}, {}
		for i, syllable in ipairs(syllables) do
			initial = match(syllable, "^?g?")
			final = match(sub(syllable, len(initial) + 1, -1), "^*")
			
			if initial == "" and find(final, "^i") then
				error('"i" ile başlayan hecelerin başına bir "y" konmalı.')
			end
			
			final = gsub(gsub(final, "^yi", "i"), "^y", "i")
			
			if find(initial, "") and final == "i" then
				final = "ii"
			end
			if final == "" then
				final = initial
				initial = ""
			end
			tone = match(syllable, "$")
		end
		for i, syllable in ipairs(syllables) do
			initial = (find(final, "^i") and palatal] or initial_conv]) or error(("Unrecognised initial: \"%s\""):format(initial))
			final = final_conv] or error(("Tanınmayan bitiş: \"%s\""):format(final))
			if find(initial, "s") and find(final, "^i") then
				error("Dilönü başlangıcı gerekli.")
			end
			if find(initial, "ɕ") and find(final, "^") then
				error("Kafiye ile uyumsuz dilönü başlangıcı.")
			end
			if match(tone, "") and match(tone or "", "") then
				tone = tone .. "*"
			end
			if initial == "" and final == "e" and tone == "3" and find(mw.title.getCurrentTitle().text, '仔') then
				initial = match(final or '', '()̚?$') or initial
				initial = find(final or '', 'u$') and 'ʋ' or initial
				initial = find(final or '', '$') and '(ʋ)' or initial
				initial = find(final or '', 'e$') and '(i)' or initial
			end
			tone = tone_conv]
			ipa = initial .. final .. tone
		end
		table.insert(result, table.concat(ipa, " "))
	end
	return table.concat(result, "/, /")
end

return export