Module:User:Fenakhay/mt-IPA

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


local export = {}

local rfind = mw.ustring.find
local rsubn = mw.ustring.gsub

local m_q = require("Module:qualifier")
local m_IPA = require("Module:IPA")

local sc = require("Module:scripts").getByCode("Latn")
local lang = require("Module:languages").getByCode("mt")

function export.show(frame)
    local args = frame:getParent().args
    local pagetitle = mw.title.getCurrentTitle().text

    local p, results_archaic_rural = {}, {}

    if args then
        for index, item in ipairs(args) do
            table.insert(p, (item ~= "") and item or nil)
        end
    else
        p = {pagetitle}
    end

    for _, word in ipairs(p) do
        table.insert(results_archaic_rural, {pron = "/" .. export.mt_archaic_rural_IPA(word) .. "/"})
    end

    return m_IPA.format_IPA_full { lang = lang, items = results }
end

-- version of rsubn() that discards all but the first return value
local function rsub(term, foo, bar)
	local retval = rsubn(term, foo, bar)
	return retval
end

-- apply rsub() repeatedly until no change
local function rsub_repeatedly(term, foo, bar)
	while true do
		local new_term = rsub(term, foo, bar)
		if new_term == term then
			return term
		end
		term = new_term
	end
end

local vowels = "aeiyouâêîôû"
local vowel = ""
local consonant = ""
local voiceless_consonant = "ptkqzċfsxħ"
local voiced_consonant = "bdgẓġvzžḡʕ"

local vowel_correspondences = {
     = "ɪ",
     = "ɪ",
     = "iː",
     = "ɪː",
     = "ɔ",
     = "ɔ",
     = "ɔː",
     = "ɛ",
     = "ɛ",
     = "ɛː",
     = "u",
     = "u",
     = "uː",
     = "a",
     = "a",
     = "aː",
     = "ɛˤː",
     = "aˤː",
     = "ɔˤː",
     = "əˤ"
}

local devoicing = {
     = "p",
     = "k",
     = "f",
     = "ċ",
     = "x",
     = "t",
     = "ħ",
     = "ħ",
     = "Z"
}

local voicing = {
     = "b",
     = "g",
     = "v",
     = "ġ",
     = "ž",
     = "d",
     = "ẓ",
}

local consonant_correspondences = {
     = "d͡ʒ",
     = "ɡ",
     = "ʃ",
     = "t͡ʃ",
     = "ʔ",
     = "t͡s",
     = "z",
     = "d͡z",
     = "ʕ",
     = "ɣ",
     = "ʒ",
}

function export.mt_IPA(text, variant, do_debug)
	
	text = rsubn(text, "-", "")
	
	text = rsubn(text, " | ", "# | #")
	text = "##" .. rsubn(text, " ", "# #") .. "##"
	
	text = mw.ustring.lower(text)
	
    -- Replace ie with y
    text = rsubn(text, "ie", "y")
	-- Replace għ with ʕ
    text = rsubn(text, "għ", "ʕ")
	-- Replace ḡ with ʕ if archaic
    if variant == "archaic" then text = rsubn(text, "ḡ", "ʕ") end
    -- Replace final h with ħ
    text = rsubn(text, "h#", "ħ#")
	
    -- Replace z with Z (temp)
    text = rsubn(text, "z", "Z")
    
    local function epenthetic_vowel_add(cons1, cons2)
    	if rfind(cons1, "") or cons1 == cons2 then
	    	return "##(ɪ)" .. cons1 .. cons2
	    end
    end
    
    text = rsubn(text, "##(" .. consonant .. ")(" .. consonant .. ")", epenthetic_vowel_add)
    
	text = rsubn(text, "ZZ()", "ẓẓ%1")
    
    -- Simplify affricate geminates
    text = rsubn(text, "()%1", "d%1")
    text = rsubn(text, "()%1", "t%1")

    -- Replace ʕh, ħh, hh with ħħ
    text = rsubn(text, "h", "ħħ")

    -- Replace âho, aho with ô
    text = rsubn(text, "ho", "ô")
    -- Replace êhi, ehi with èj
    text = rsubn(text, "hi", "èj")
    -- Replace ûho, ùho with ûwo
    text = rsubn(text, "ho", "ûwo")
    -- Replace îħ with yħ
    text = rsubn(text, "()", "y%1")
    -- Replace yha with yja
    text = rsubn(text, "yha", "yja")

    -- Replace eh, he with ê
    text = rsubn(text, "h", "ê")
    text = rsubn(text, "h", "ê")

    -- Replace ah, ha with â
    text = rsubn(text, "h", "â")
    text = rsubn(text, "h", "â")
    text = rsubn(text, "ha", "â")
    
    -- Replace ih, hi with î
    text = rsubn(text, "h", "î")
    
    -- Replace vowel + għ + vowel with vowel + ˤː
    text = rsubn(text, "ʕ", "é")
    text = rsubn(text, "ʕ", "á")
    text = rsubn(text, "ʕ", "ó")
    -- Replace consonant + e + għ + consonant with consonant + ɛˤː + consonant
    text = rsubn(text, "(" .. consonant .. ")ʕ(" .. consonant .. ")", "%1é%2")
    -- Replace consonant + a + għ + consonant with consonant + aˤː + consonant
	text = rsubn(text, "(" .. consonant .. ")ʕ(" .. consonant .. ")", "%1á%2")
    -- Replace consonant + ɔ + għ + consonant with consonant + ɔˤː + consonant
	text = rsubn(text, "(" .. consonant .. ")ʕ(" .. consonant .. ")", "%1ó%2")
    -- Replace initial għ + î with əˤjː
    text = rsubn(text, "ʕî", "æj")
    -- Replace initial għ + e with əˤ
    text = rsubn(text, "ʕe", "æ")
    -- Replace initial għ + u,û with əˤwː
    text = rsubn(text, "ʕ", "æw")
    -- Replace initial għ + vowel with vowel + ˤː
    text = rsubn(text, "ʕ", "é")	
    text = rsubn(text, "ʕ", "á")
    text = rsubn(text, "ʕ", "ó")
    
    text = rsubn(text, "a'#", "aˤ#")
    
    -- text = rsubn(text, "êî", "ejî")
    
    local function voice(sound, following)
		return voicing .. following
    end
    
    local function devoice(sound, following)
		return devoicing .. following
    end
    
    local function final_devoicing(sound)
		return devoicing
    end

	-- Final devoicing
	text = rsub_repeatedly(text, "()#", final_devoicing)
	
	text = rsub_repeatedly(text, "()()", voice)
	text = rsub_repeatedly(text, "()()", devoice)
	
    local function simplify_final_geminates(cons1, cons2)
    	if cons1 == cons2 and not rfind(cons1, "") then
	    	return cons2 .. "#"
	    end
    end
    
    text = rsubn(text, "(" .. consonant .. ")(" .. consonant .. ")#", simplify_final_geminates)
    
    -- Replace îħ with yħ
    text = rsubn(text, "()", "y%1")
    
    -- Replace îħ with yħ
    text = rsubn(text, "ts", "Z")
    text = rsubn(text, "dz", "ẓ")
    
    -- Replace consonants
    text = rsubn(text, ".", consonant_correspondences)
    -- Replace vowels
    text = rsubn(text, ".", vowel_correspondences)
    
	text = rsubn(text, "h", "")
	text = rsubn(text, "#", "")

    return text
end

return export