Module:et-IPA/old

Hello, you have come here looking for the meaning of the word Module:et-IPA/old. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:et-IPA/old, but we will also tell you about its etymology, its characteristics and you will know how to say Module:et-IPA/old in singular and plural. Everything you need to know about the word Module:et-IPA/old you have here. The definition of the word Module:et-IPA/old will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:et-IPA/old, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

This module implements {{et-IPA}}.


local export = {}

local m_IPA = require("Module:IPA")
local lang = require("Module:languages").getByCode("et")

local letters_phonemes = {
	 = "ɑ",  = "ɑː",
	 = "e",  = "eː",
	 = "i",  = "iː",
	 = "o",  = "oː",
	 = "u",  = "uː",
	 = "ɤ",  = "ɤː",
	 = "æ",  = "æː",
	 = "ø",  = "øː",
	 = "y",  = "yː",
	
	 = "eɑ̯",
	 = "oɑ̯",
	 = "ɤɑ̯",
	 = "øɑ̯",
	 = "yɑ̯",
	
	 = "ɑe̯",
	 = "oe̯",
	 = "ɤe̯",
	 = "æe̯",
	 = "øe̯",
	
	 = "ɑi̯",
	 = "ei̯",
	 = "oi̯",
	 = "ui̯",
	 = "ɤi̯",
	 = "æi̯",
	 = "øi̯",
	 = "yi̯",
	
	 = "ɑo̯",
	 = "eo̯",
	 = "uo̯",
	 = "ɤo̯",
	 = "æo̯",
	
	 = "ɑu̯",
	 = "iu̯",
	 = "ou̯",
	 = "ɤu̯",
	 = "æu̯",
	
	  = "b̥",
	  = "d̥",
	 = "d̥ʲ",
	  = "ɡ̊",
	
	  = "p" ,   = "pː",
	  = "t" ,   = "tː",
	 = "tʲ",  = "tʲː",
	  = "k" ,   = "kː",
	
	  = "f" ,   = "fː",
	  = "h" ,   = "hː",
	  = "s" ,   = "sː",
	 = "sʲ",  = "sʲː",
	
	  = "l",    = "lː",
	 = "lʲ",  = "lʲː",
	  = "r",    = "rː",
	  = "m",    = "mː",
	  = "n",    = "nː",
	 = "nʲ",   = "nʲː",
	  = "ŋɡ̊",    = "ŋk",
	  = "j",    = "jː",
	  = "v",    = "vː",
	
	 = "ʃ",  = "ʃː",
	 = "ʒ",  = "ʒː",
	
	 = "ˈ",  = "ˈ",
}

local function IPA_word(word)
	-- Make everything lowercase so we don't have to deal with case differences
	word = mw.ustring.lower(word)
	
	local rest = word
	local phonemes = {}
	
	while mw.ustring.len(rest) > 0 do
		-- Find the longest string of letters that matches a recognised sequence in the list
		local longestmatch = ""
		
		for letter, phoneme in pairs(letters_phonemes) do
			if mw.ustring.sub(rest, 1, mw.ustring.len(letter)) == letter and mw.ustring.len(letter) > mw.ustring.len(longestmatch) then
				longestmatch = letter
			end
		end
		
		-- Convert the string to IPA
		if mw.ustring.len(longestmatch) > 0 then
			table.insert(phonemes, letters_phonemes)
			rest = mw.ustring.sub(rest, mw.ustring.len(longestmatch) + 1)
		else
			-- If no match was found, just insert the character as it is
			table.insert(phonemes, mw.ustring.sub(rest, 1, 1))
			rest = mw.ustring.sub(rest, 2)
		end
	end
	
	local ipa = table.concat(phonemes)
	
	-- Add default stress mark is one is not already present
	if not mw.ustring.find(ipa, "ˈ") then
		ipa = "ˈ" .. ipa
	end
	
	return ipa
end

function export.IPA(frame)
	local words = {}
	
	for _, word in ipairs(frame:getParent().args) do
		table.insert(words, word)
	end
	
	if #words == 0 then
		words = {mw.title.getCurrentTitle().text}
	end
	
	for key, word in ipairs(words) do
		words = IPA_word(word)
	end
	
	return m_IPA.format_IPA_full { lang = lang, items = {{pron = "/" .. table.concat(words) .. "/"}} }
end

return export