Jump to content

Module:ckb-pron

From Wiktionary, the free dictionary

Pronunciation module for Central Kurdish. See {{ckb-IPA}}.

For testcases, see Module:ckb-pron/testcases.


-- Authors: Ghybu, Calak
local m_IPA = require("Module:IPA")
local lang = require("Module:languages").getByCode("ckb")

local export = {}

local letters1_phonemes = {
	["a"] = "aː",
    ["b"] = "b",
	["c"] = "d͡ʒ",
    ["ç"] = "t͡ʃ",
	["d"] = "d",
	["e"] = "a",
	["ê"] = "e̞ː",
	["f"] = "f",
	["g"] = "ɡ",
	["h"] = "h",
	["ḧ"] = "ħ",
	["i"] = "ə",
	["î"] = "iː",
	["j"] = "ʒ",
	["k"] = "k",
	["l"] = "l",
	["m"] = "m",
	["n"] = "n",
	["o"] = "o̞ː",
	["p"] = "p",
	["q"] = "q",
	["r"] = "ɾ",
	["s"] = "s",
	["ş"] = "ʃ",
	["t"] = "t",
	["u"] = "ʊ",
	["û"] = "uː",
	["v"] = "v",
	["w"] = "w",
	["x"] = "x",
	["ẍ"] = "ɣ",
	["y"] = "j",
	["z"] = "z",
	["'"] = "ʕ",
}

function export.phonemic(word)
	word = mw.ustring.gsub(word,'ئ','ʔ')
	
	word = lang:transliterate(word)
		
	word = mw.ustring.gsub(word, '.', letters1_phonemes)

	word = mw.ustring.gsub(word, '([ːaʊə])j([^aəʊiueo])', "%1i̯%2") -- diphthongs: ay, oy, ûy, êy, ey
	word = mw.ustring.gsub(word, '([ːaʊə])j$', "%1i̯") -- diphthongs: ay, oy, ûy, êy, ey
	word = mw.ustring.gsub(word, '([ːaʊə])w([^aəʊiueo])', "%1u̯%2") -- diphthongs: aw, ow, îw, êw, ew
	word = mw.ustring.gsub(word, '([ːaʊə])w$', "%1u̯") -- diphthongs: aw, ow, îw, êw, ew
	
	word = mw.ustring.gsub(word, 'ai̯', "ɛi̯") -- diphthong ey
	word = mw.ustring.gsub(word, '̞ː([iu])', "ː%1") -- removing ̞
	word = mw.ustring.gsub(word, '([bʒdɡknqsʃt])weː([iu])', "%1øe%2") -- diphthong öy, öw
	word = mw.ustring.gsub(word, '([bʒdɡknqsʃt])we̞ː', "%1øe̯") -- diphthong ö
	
	word = mw.ustring.gsub(word,'n([ɡk])',"ŋ%1") -- velarized n before velar plosive consonants
	word = mw.ustring.gsub(word, 'k([ieøj])', "c%1") -- palataized k before y and front vowels
	word = mw.ustring.gsub(word, 'ɡ([ieøj])', "ɟ%1") -- palataized g before y and front vowels
    word = mw.ustring.gsub(word, '^ɾ', "r") -- initial r should be trill
    word = mw.ustring.gsub(word,'ɾɾ',"r") -- trill r
    word = mw.ustring.gsub(word, 'll', "ɫ") -- velarized l
	
	word = mw.ustring.gsub(word, 'ja([^ː])', "jɛ%1") -- ye
	word = mw.ustring.gsub(word, 'o̞ː([rɾ])', "ɔː%1") -- or(r)	
	
	return word
end

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

	local args = frame:getParent().args
	local currentTitle = mw.title.getCurrentTitle().text

	for _, term in ipairs(args) do
		if term == currentTitle then track("redundant") end
		table.insert(terms, term)
	end

	if #terms == 0 then
		terms = {currentTitle}
	end

	local results = {}

	for _, term in ipairs(terms) do
		table.insert(results, {pron = "/" .. export.phonemic(term) .. "/"})
	end

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

return export