Modul:fi-pronunciation

Üdvözlöm, Ön a Modul:fi-pronunciation szó jelentését keresi. A DICTIOUS-ban nem csak a Modul:fi-pronunciation szó összes szótári jelentését megtalálod, hanem megismerheted az etimológiáját, a jellemzőit és azt is, hogyan kell a Modul:fi-pronunciation szót egyes és többes számban mondani. Minden, amit a Modul:fi-pronunciation szóról tudni kell, itt található. A Modul:fi-pronunciation szó meghatározása segít abban, hogy pontosabban és helyesebben fogalmazz, amikor beszélsz vagy írsz. AModul:fi-pronunciation és más szavak definíciójának ismerete gazdagítja a szókincsedet, és több és jobb nyelvi forráshoz juttat.

A modult a Modul:fi-pronunciation/doc lapon tudod dokumentálni

local export = {}

local m_IPA = require("Module:IPA")
local m_fi_IPA = require("Module:fi-IPA") -- <= the module you want to edit if the IPA transcription is wrong
local m_hyph = require("Module:fi-hyphenation") -- <= the module you want to edit if the automatic hyphenation is wrong
local m_qual = require("Module:qualifier")

local lang = require("Module:languages").getByCode("fi")

local vowels = "aeiouyåäö"
local vowel = ""
local consonants = "bcdfghjklmnpqrstvwxzšžʔ"
local consonant = ""
local apostrophe = "’"	
local tertiary = m_fi_IPA.tertiary
local ipa_symb = "ˣˈˌ"..tertiary.."̯̝̞̠̪" -- include ˣ because final gemination does not affect rhymes

local function clean_for_hyphenation(word)
	return mw.ustring.gsub(mw.ustring.gsub(mw.ustring.gsub(mw.ustring.gsub(word, "%(%)", ""), "(.)ː", "%1%1"), "", ""), "/", "-")
end
export.h = clean_for_hyphenation

-- applies gemination mid-word for rhymes
local function apply_gemination(word)
	return mw.ustring.gsub(mw.ustring.gsub(word, "(" .. vowel .. ")", "ʔ%1"), "(" .. consonant .. ")", "%1ː")
end

local function clean_for_rhyme(word)
	return mw.ustring.gsub(mw.ustring.gsub(mw.ustring.gsub(mw.ustring.gsub(apply_gemination(mw.ustring.lower(word)), "%(%)", ""), "(.)ː", "%1%1"), "", ""), "/", "-")
end

function export.generate_rhyme(word)
	-- convert syllable weight to hyphen for next routine
	-- (just in case these are included manually... even if they shouldn't be)
	local fmtword = mw.ustring.gsub(word, "", "-")
	fmtword = mw.ustring.gsub(word, "’", ".")
	
	-- get final part of a compound word
	local last_hyph = mw.ustring.find(fmtword, "%-*$") or 0
	local last_part = mw.ustring.sub(fmtword, last_hyph + 1)
	
	-- split to syllables, keep . in case we have a syllable break
	local hyph = m_hyph.generate_hyphenation(last_part, ".")
	local last_index = #hyph
	local last_stressed = 1
	local prev_stress = false
	
	-- find last stressed syllable
	for index, syllable in ipairs(hyph) do
		local stressed = false
		
		if index == 1 then
			stressed = true
		elseif not prev_stress and index < last_index then
			-- shift stress if current syllable light and a heavy syllable occurs later
			stressed = index == last_index - 1 or not m_fi_IPA.is_light_syllable(syllable) or not m_fi_IPA.has_later_heavy_syllable(hyph, index + 1)
		end
		
		if stressed then
			last_stressed = index
		end
		prev_stress = stressed
	end
	
	local res = {}
	for i = last_stressed, #hyph, 1 do 
		table.insert(res, hyph)	
	end
	
	res = table.concat(res)
	
	-- remove initial consonants, convert to IPA, remove IPA symbols
	res = mw.ustring.gsub(res, "^%.", "")
	res = mw.ustring.gsub(res, "^" .. consonant .. "+", "")
	res = m_fi_IPA.IPA_wordparts(res, false)
	res = mw.ustring.gsub(res, "", "")
	res = mw.ustring.gsub(res, "^%.", "")
	
	return res
end

local function pron_equal(title, pron)
	if not pron or pron == "" then
		return true
	end
	
	-- handle slashes as hyphens
	pron = mw.ustring.gsub(pron, "/", "-")
	-- remove gemination asterisks and syllable separating dots
	pron = mw.ustring.gsub(pron, "*", "")
	pron = mw.ustring.gsub(pron, "%.", "")
	-- remove optional lengthening/shortening, should not cause any issues
	pron = mw.ustring.gsub(pron, "%(%)", "")
	-- map existing glottal stops to apostrophes
	pron = mw.ustring.gsub(pron, "%(?ʔ%)?", apostrophe)
	-- /ŋn/ for /gn/ is fine
	pron = mw.ustring.gsub(pron, "ŋn", "gn")
	-- remove hyphens but also apostrophes right after hyphens
	-- (so that glottal stop is allowed after hyphen separating two same vowels)
	pron = mw.ustring.gsub(pron, "-" .. apostrophe .. "?", "")
	title = mw.ustring.gsub(title, "-", "")
	
	return pron == mw.ustring.lower(title)
end

function export.show(frame)
	local title = mw.title.getCurrentTitle().text
	local pronunciation = { "" }
	local ipa = { nil }
	local rhymes = { nil }
	local hyphenation = { nil }
	local audio = { }
	local qualifiers = { }
	local hyphlabels = { }
	local rhymlabels = { }
	local homophones = { }
	local homophonelabels = { }
	local nohyphen = false
	local norhymes = false
	
	if type(frame) == "table" then
		local params = {
			 = { list = true, default = "" },
			
			 = { list = true, default = nil, allow_holes = true },
			 = { list = true, default = nil, allow_holes = true },  = {},
			 = { list = true, default = nil, allow_holes = true },  = {},
			 = { list = true, default = nil },  = {},
			 = { list = true, default = nil },  = {},
			 = { default = "" },  = {},
			
			 = { list = true, default = nil, allow_holes = true },
			 = { list = true, default = nil, allow_holes = true },
			 = { list = true, default = nil, allow_holes = true },
			 = { list = true, default = nil, allow_holes = true },
			
			 = { type = "boolean", default = false },
			 = { type = "boolean", default = false },
			
			 = {}, -- for debugging or demonstration only
		}
		
		local args, further = require("Module:parameters").process(frame:getParent().args, params, true)
		
		title = args or title
		pronunciation = args
		ipa = args
		hyphenation = args
		rhymes = args
		qualifiers = args
		hyphlabels = args
		rhymlabels = args
		nohyphen = args
		norhymes = args
		homophones = mw.text.split(args, ",")
		homophonelabels = args
		
		if #homophones == 1 and homophones == "" then homophones = {} end
		if args then hyphenation = args end
		if args then rhymes = args end
		if args then homophones = mw.text.split(args, ",") end
		
		-- messy
		if ipa and ipa == nil then ipa = "" end
		
		local audios = args
		local captions = args
		if args then audios = args end
		if args then captions = args end
		
		for i, audiofile in ipairs(audios) do
			if audiofile then
				table.insert(audio, {file = audiofile, caption = captions or "Audio"})
			end
		end
	end

	for i, p in ipairs(pronunciation) do
		if p == "" then
			pronunciation = title
		elseif p == "*" then
			pronunciation = title .. p
		end
	end
	
	-- make sure #pronunciation >= #IPA
	for i, p in ipairs(ipa) do
		if not pronunciation then
			pronunciation = ""
		end
	end
	
	local manual_hr = false
	local ripa = {}
	
	local has_spaces = mw.ustring.match(title, " ")
	local is_suffix = mw.ustring.match(title, "^-")
	local is_prefix_or_suffix = mw.ustring.match(title, "-$") or is_suffix
	for i, p in ipairs(pronunciation) do
		local qual = qualifiers or ""
		
		if #qual > 0 then
			qual = " " .. m_qual.format_qualifier(qualifiers)
		end
		
		if ipa and ipa ~= "" then
			table.insert(ripa, "* " .. m_IPA.format_IPA_full(lang, {{pron = ipa}}, nil, nil, nil, has_spaces) .. qual)
			manual_hr = true
		else
			p = mw.ustring.gsub(p, ":", "ː")
			
			local IPA_narrow = m_fi_IPA.IPA_wordparts(p, true)
			local IPA = m_fi_IPA.IPA_wordparts(p, false)
			
			-- multi-word stress
			if has_spaces then
				IPA_narrow = mw.ustring.gsub(IPA_narrow, " ()", " ˈ%1")
				IPA = mw.ustring.gsub(IPA, " ()", " ˈ%1")
			end
			
			-- remove initial stress if suffix
			if is_suffix then
				IPA_narrow = mw.ustring.gsub(IPA_narrow, "^ˈ", "")
				IPA = mw.ustring.gsub(IPA, "^ˈ", "")
			end
			
			table.insert(ripa, "* " .. m_IPA.format_IPA_full(lang, {{pron = "/" .. IPA .. "/"}, {pron = ""}}, nil, nil, nil, has_spaces) .. qual)
		end
	end
	
	local results = mw.clone(ripa)
	manual_hr = manual_hr or has_spaces or is_prefix_or_suffix or not pron_equal(title, mw.ustring.lower(pronunciation))
	
	if not hyphenation and not manual_hr then
		hyphenation = m_hyph.generate_hyphenation(clean_for_hyphenation(pronunciation), false)
	end
	if not rhymes and not manual_hr then
		rhymes = export.generate_rhyme(clean_for_rhyme(pronunciation))
	end
	
	if #hyphenation == 1 and hyphenation == "-" then
		hyphenation = {}
	end
	if #rhymes == 1 and rhymes == "-" then
		rhymes = {}
	end
	
	for i, h in ipairs(hyphenation) do
		if type(h) == "string" then
			hyphenation = mw.text.split(h, '')
		end
	end
	
	for i, a in ipairs(audio) do
		table.insert(results, "* " .. frame:expandTemplate{title = "audio", args = {"fi", a, a}})
	end
	
	if not norhymes then
		if #rhymes > 0 then
			-- merge rhymes if they have identical labels
			local last_label = false
			local new_rhymes = {}
			local new_labels = {}
			local current_list = {}
			
			for i, r in ipairs(rhymes) do
				local label = rhymlabels
				if last_label == label then
					table.insert(current_list, r)
				else
					if #current_list > 0 then
						table.insert(new_rhymes, current_list)
					end
					if last_label ~= false then
						table.insert(new_labels, last_label)
					end
					current_list = { r }
					last_label = label
				end
			end
			
			table.insert(new_rhymes, current_list)
			table.insert(new_labels, last_label)
			rhymes = new_rhymes
			rhymlabels = new_labels
		end
		
		for i, r in ipairs(rhymes) do
			local label = ""
			if rhymlabels then
				label = " " .. m_qual.format_qualifier(rhymlabels)
			end
			if #r >= 1 then
				table.insert(results, "* " .. frame:expandTemplate{title = "rhymes", args = {"fi", unpack(r)}} .. label)
			end
		end
	end
	if #homophones > 0 then
		local homophone_param = {"fi"}
		for i, h in ipairs(homophones) do
			table.insert(homophone_param, h)
			if homophonelabels then
				homophone_param = homophonelabels
			end
		end
		table.insert(results, "* " .. frame:expandTemplate{title = "homophones", args = homophone_param})
	end
	if not nohyphen then
		for i, h in ipairs(hyphenation) do
			local label = ""
			if hyphlabels then
				label = " " .. m_qual.format_qualifier(hyphlabels)
			end
			table.insert(results, "* szótagolás: " .. require("Module:links").full_link({lang = lang, alt = table.concat(h, "‧"), tr = "-"}) .. label)
		end
	end
	
	return table.concat(results, "\n")
end

return export