Module:sandbox/cu-pronunciation

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

Testcases

Module error: No such module "cu-pronunciation/sandbox/testcases".


local export = {}

local rsubn = mw.ustring.gsub
local U = mw.ustring.char

local TIE = U(0x361)
local BREVE = U(0x306)
local DENTAL = U(0x32A)
local SYLLABIC = U(0x329)
local FRONTED = U(0x31F)
local RETRACTED = U(0x320)
local NASAL= U(0x303)
local GRAVE = U(0x300)
local D_GRAVE = U(0x30F)
local HIGH_TONE = U(0x2E6)
local LOW_TONE = U(0x2E8)
local vowels = "aæɛiɪɔuʊɯy"
local vowels_c = ""
local palatal_cons = "ʃʒjʲɲɕʑʎ"
local cons = "bvɡdʒzjkɫʎmnɲpɾrstfxʃɕʑ"  .. TIE .. BREVE .. DENTAL
local diacritics = TIE .. BREVE .. DENTAL .. SYLLABIC .. FRONTED  .. RETRACTED .. NASAL
local tones = HIGH_TONE .. LOW_TONE

-- characters that map to IPA sounds
local phonetic_chars_map = {
	 = "ɑ",
	 = "b",
	 = "v",
	 = "ɡ",
	 = "d" .. DENTAL,
	 = "ɛ" .. RETRACTED,
	 = "ɛ" .. RETRACTED,
	 = "ʒ",
	 = "d" .. DENTAL .. TIE .. "z" .. DENTAL,
	 = "d" .. TIE .. "z",
	 = "z" .. DENTAL,
	 = "z" .. DENTAL,
	 = "i",
	 = "jь",
	 = "i",
	 = "i",
	 = "k",
	 = "ɫ" .. DENTAL,
	 = "m",
	 = "n" .. DENTAL,
	 = "ɔ" .. FRONTED,
	 = "p",
	 = "ɾ" .. DENTAL,
	 = "s" .. DENTAL,
	 = "t" .. DENTAL,
	 = "u",
	 = "f",
	 = "x",
	 = "ɔt" .. DENTAL .. "ʊ" .. BREVE,
	 = "t" .. DENTAL .. TIE .. "s" .. DENTAL,
	 = "t" .. TIE .. "ʃ",
	 = "ʃ",
	 = "ʃt",
	 = "ɯ",
	 = "ɯ",
	 = "æ",
	 = "ɔ" .. NASAL,
	 = "ɛ" .. NASAL,
	 = "ɛ" .. NASAL,
	 = "ju",
	 = "jɑ",
	 = "jɛ" .. RETRACTED,
	 = "jæ",
	 = "jɛ" .. NASAL,
	 = "jɛ" .. NASAL,
	 = "jɔ" .. NASAL,
	 = "t" .. DENTAL,
	 = "kʊ" .. BREVE .. "s" .. DENTAL,
	 = "pʊ" .. BREVE .. "s" .. DENTAL,
	 = "ɔ",
	 = "ʒd",
	 = "ɔ",
	 = "ɔ",
	 = "ɔ",
	 = "y",
	 = "y",
	 = "ʲ",
	 = "ʲ"
}

-- 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
 
function export.toIPA(term)
	term = mw.ustring.toNFC(mw.ustring.lower(term))

	-- Change Cyrillic glyphs to IPA symbols
	term = rsub(term, ".", phonetic_chars_map)
	-- Change y into its actual sound value
	term = rsub(term, "ɔ" .. FRONTED .. "y", "u")
	term = rsub(term, "()y", "%1v")
	term = rsub(term, "()y", "%1v")
	term = rsub(term, "()y", "%1v")
	term = rsub(term, "()y", "%1i")
	-- Change j to ʲ after consonants
	term = rsub(term, "()j", "%1ʲ")
	-- Palatalize vowels
	term = rsub(term, "()ɑ", "%1æ")
	term = rsub(term, "()u", "%1y")
	term = rsub(term, "()ɔ" .. NASAL, "%1ɛ" .. NASAL)
	-- Palatalize dental consonants
	term = rsub(term, "ɫ" .. DENTAL .. "ʲ", "ʎ")
	term = rsub(term, "ɾ" .. DENTAL .. "ʲ", "ɾʲ")
	term = rsub(term, "n" .. DENTAL .. "ʲ", "ɲ")
	term = rsub(term, "ʒd" .. DENTAL, "ʒd")
	term = rsub(term, "ʃt" .. DENTAL, "ʃt")
	-- Handle nasal gamma in Greek loanwords
	term = rsub(term, "" .. DENTAL .. "?()", "n" .. DENTAL .. "ъ%1")
	-- Raise tense yers
	term = rsub(term, "ъj", "ɯj")
	term = rsub(term, "ьj", "ij")
	-- Remove yers succeeding a syllabic liquid
	term = rsub(term, "()ɾ" .. DENTAL .. "", "%1r" .. SYLLABIC)
	term = rsub(term, "()ɫ" .. DENTAL .. "", "%1ɫ" .. SYLLABIC)
	-- Allophone of ɫ before front vowels
	term = rsub(term, "ɫ" .. DENTAL .. "()", "l" .. DENTAL .. "%1")
	-- Then change strong yers into IPA
	term = rsub(term, "ь()()", "ɪ%1%2")
	term = rsub(term, "ь()()", "ɪ%1%2")
	term = rsub(term, "ь()()", "ɪ%1%2")
	term = rsub(term, "ь()()", "ɪ%1%2")
	term = rsub(term, "ь()()", "ɪ%1%2")
	term = rsub(term, "ь()()", "ɪ%1%2")
	term = rsub(term, "ь()()", "ɪ%1%2")
	term = rsub(term, "ь()()", "ɪ%1%2")
	term = rsub(term, "ъ()()", "ʊ%1%2")
	term = rsub(term, "ъ()()", "ʊ%1%2")
	term = rsub(term, "ъ()()", "ʊ%1%2")
	term = rsub(term, "ъ()()", "ʊ%1%2")
	term = rsub(term, "ъ()()", "ʊ%1%2")
	term = rsub(term, "ъ()()", "ʊ%1%2")
	term = rsub(term, "ъ()()", "ʊ%1%2")
	term = rsub(term, "ъ()()", "ʊ%1%2")
	-- Finally do the same for weak yers
	term = rsub(term, "ь", "ɪ" .. BREVE)
	term = rsub(term, "ъ", "ʊ" .. BREVE)
    -- Iotate i, ɛ, ɛ̃, æ, and optionally a at the start of a word and after a vowel
	term = rsub(term, "%f()", "j%1")
	term = rsub(term, "()()", "j%1")
	term = rsub(term, "()()", "%1j%2")
	term = rsub(term, "%fɑ", "(j)ɑ")
	-- Remove unnecessary characters
	term = rsub(term, "%[", "")
	term = rsub(term, "%]", "")
	term = rsub(term, "%-", "")
	-- Convert pitch accent
	term = rsub(term, GRAVE .. "()()", LOW_TONE .. "%1%2" .. HIGH_TONE)
	term = rsub(term,  GRAVE .. "()()()", LOW_TONE .. "%1%2" .. HIGH_TONE)
	term = rsub(term, GRAVE .. "()()", LOW_TONE .. "%1%2" .. HIGH_TONE)
	term = rsub(term, GRAVE .. "()()", LOW_TONE .. "%1%2" .. HIGH_TONE)
	term = rsub(term, GRAVE .. "()()", LOW_TONE .. "%1%2" .. HIGH_TONE)
	term = rsub(term, GRAVE .. "()()", LOW_TONE .. "%1%2" .. HIGH_TONE)
	term = rsub(term, GRAVE .. "()()", LOW_TONE .. "%1%2" .. HIGH_TONE)
	term = rsub(term, GRAVE .. "()()", LOW_TONE .. "%1%2" .. HIGH_TONE)
	term = rsub(term, GRAVE .. "()()", LOW_TONE .. "%1%2" .. HIGH_TONE)
	term = rsub(term, GRAVE .. "()()", LOW_TONE .. "%1%2" .. HIGH_TONE)
	term = rsub(term, GRAVE .. "()()", LOW_TONE .. "%1%2" .. HIGH_TONE)
	term = rsub(term, GRAVE .. "()()", LOW_TONE .. "%1%2" .. HIGH_TONE)
	term = rsub(term, GRAVE .. "()()", LOW_TONE .. "%1%2" .. HIGH_TONE)
	term = rsub(term, GRAVE .. "()()", LOW_TONE .. "%1%2" .. HIGH_TONE)
	term = rsub(term, GRAVE .. "()()", HIGH_TONE .. "%1%2" .. LOW_TONE)
	term = rsub(term, GRAVE .. "()()", HIGH_TONE .. "%1%2" .. LOW_TONE)
	term = rsub(term, D_GRAVE .. "()()()", HIGH_TONE .. "%1%2" .. LOW_TONE)
	term = rsub(term, D_GRAVE .. "()()()", HIGH_TONE .. "%1%2" .. LOW_TONE)
	term = rsub(term, D_GRAVE .. "()()", HIGH_TONE .. "%1%2" .. LOW_TONE)
	term = rsub(term, D_GRAVE .. "()()", HIGH_TONE .. "%1%2" .. LOW_TONE)
	term = rsub(term, D_GRAVE .. "()()", HIGH_TONE .. "%1%2" .. LOW_TONE)
	term = rsub(term, D_GRAVE .. "()()", HIGH_TONE .. "%1%2" .. LOW_TONE)
	term = rsub(term, D_GRAVE .. "()()", HIGH_TONE .. "%1%2" .. LOW_TONE)
	term = rsub(term, D_GRAVE .. "()()", HIGH_TONE .. "%1%2" .. LOW_TONE)
	term = rsub(term, D_GRAVE .. "()()", HIGH_TONE .. "%1%2" .. LOW_TONE)
	term = rsub(term, D_GRAVE .. "()()", HIGH_TONE .. "%1%2" .. LOW_TONE)
	term = rsub(term, D_GRAVE .. "()()", HIGH_TONE .. "%1%2" .. LOW_TONE)
	term = rsub(term, D_GRAVE .. "()()", HIGH_TONE .. "%1%2" .. LOW_TONE)
	term = rsub(term, D_GRAVE .. "()()", HIGH_TONE .. "%1%2" .. LOW_TONE)
	term = rsub(term, D_GRAVE .. "()()", HIGH_TONE .. "%1%2" .. LOW_TONE)
	return term
end

function export.show(frame)
	local params = {
		 = {}
	}

	local title = mw.title.getCurrentTitle()
	
	local args = require("Module:parameters").process(frame:getParent().args, params)
	local term = args or title.nsText == "Template" and "примѣръ" or title.text
	
	local ipa = export.toIPA(term)

	ipa = ""
	ipa = require("Module:IPA").format_IPA_full { lang = require("Module:languages").getByCode("cu"), items = {{ pron = ipa }} }

	return ipa
end

return export