Module:hsb-IPA

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


local export = {}

local m_IPA = require("Module:IPA")
local lang = require("Module:languages").getByCode("hsb")
local rsub = mw.ustring.gsub
local rlower = mw.ustring.lower

local C = ""
local V = ""
local T = ""
local D = ""

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 di = {
	="x",
	="dʒ",
	="tS",
	="ɥ",
}

local phon = {
	="a",
	="b",
	="ts",
	="tʃ",
	="tʃ",
	="d",
	="ɛ",
	="ɪ",
	="f",
	="ɡ",
	="ɦ",
	="i",
	="j",
	="k",
	="l",
	="w",
	="m",
	="n",
	="jn",
	="ɔ",
	="ʊ",
	="p",
	="kʰ",
	="ʀ",
	="ʃ",
	="s",
	="ʃ",
	="t",
	="u",
	="w",
	="v",
	="ɨ",
	="z",
	="ʒ",
}

local devoicing = {
     = "p",
     = "t",
     = "k",
     = "s",
     = "f",
     = "ʃ",
}

local voicing = {
     = "b",
     = "d",
     = "ɡ",
     = "z",
     = "v",
     = "ʒ",
}

local function phonemic(text)
	text = rlower(text)
	
	text = rsub(text, " | ", "# | #")
	text = "##" .. rsub(text, " ", "# #") .. "##"
	
	-- basic phonology
	text = rsub(text, "ts", "tss")
	text = rsub(text, "..", di)
	text = rsub("1" .. text, "..", di)
	text = rsub("1" .. text, "..", di)
	text = rsub(text, "1", "")
	text = rsub(text, ".", phon)
	-- 
	text = rsub(text, "#x", "#kʰ")
	--
	text = rsub(text, "X", "x")
	--
	text = rsub(text, "#sx", "skʰ")
	--
	text = rsub(text, "#zɦ", "z")
	-- palatalisation
	text = rsub(text, "jʲ", "j")
	-- h
	text = rsub(text, "ɦ#", "")
	text = rsub(text, "ɦ("..C..")", "%1")
	-- ł
	text = rsub(text, "("..C..")w$", "%1")
	text = rsub(text, "("..C..")w("..C..")", "%1%2")
	-- w
	text = rsub(text, "("..C..")v$", "%1")
	text = rsub(text, "("..C..")v("..C..")", "%1%2")
		
	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

	--v voicing
	text = rsub(text, "(" .. T .. ")v", "%1f")
	
	-- Final devoicing
	text = rsub_repeatedly(text, "(" .. D .. ")#", final_devoicing)
	
	text = rsub_repeatedly(text, "(" .. T .. ")(" .. D .. ")", voice)
	text = rsub_repeatedly(text, "(" .. D .. ")(" .. T .. ")", devoice)
	
	-- stress
	if mw.ustring.find(text, "'") == nil then
		text = "ˈ" .. text
	end
	text = rsub(text, "^(" .. C .. "+ʲ?)'", "'%1")
	text = rsub(text, " (" .. C .. "+ʲ?)'", " '%1")
	text = rsub(text, "(" .. C .. "ʲ?)'", "'%1")
	text = rsub(text, "t's", "'ts")
	text = rsub(text, "'", "ˈ")
	-- affricates
	text = rsub(text, "t()", "t͡%1")
	text = rsub(text, "d()", "d͡%1")
	-- suffixes
	text = rsub(text, "^ˈ%-", "")
	-- resolution
	text = rsub(text, "wʲ", "w")
	text = rsub(text, "jʲ", "j")
	-- tř
	text = rsub(text, "tS", "tʃ")
	
	text = rsub(text, "#", "")

	text = rsub(text, "-", "")
	
	return text
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
	
	local IPA_results = {}
	
	for _, word in ipairs(words) do
		table.insert(IPA_results, { pron = "/" .. phonemic(word) .. "/" })
	end
	
	return m_IPA.format_IPA_full { lang = lang, items = IPA_results }
end

return export