local export = {}
local m_IPA = require("Module:IPA")
local lang = require("Module:languages").getByCode("sdh")
local function track(page)
require("Module:debug").track("sdh-pron/" .. page)
return true
end
local letters1_phonemes = {
["ا"] = "ɑː",
["ب"] = "b",
["ج"] = "d͡ʒ",
["چ"] = "t͡ʃ",
["د"] = "d",
["ە"] = "æ",
["ێ"] = "eː",
["ئ"] = "ə",
["ف"] = "f",
["گ"] = "ɡ",
["ه"] = "h",
[""] = "ɪ",
["ژ"] = "ʒ",
["ک"] = "k",
["ل"] = "l",
["م"] = "m",
["ن"] = "n",
["ۆ"] = "oː",
["پ"] = "p",
["ق"] = "q",
["غ"] = "q",
["ر"] = "ɾ",
["س"] = "s",
["ش"] = "ʃ",
["ت"] = "t",
["و"] = "ʊ",
["وو"] = "uː",
["ڤ"] = "v",
["و"] = "w",
["خ"] = "x",
["یـ"] = "j",
["ـیـ"] = "iː",
["ـی"] = "iː",
["ی"] = "j",
["ز"] = "z",
-- Tîpên taybet (soranî)
["ẍ"] = "ɣ", -- mînak: aẍa
["ḧ"] = "ħ",
["ʿ"] = "ʕ",
["'"] = "ʕ",
-- ["ڵ"] = "ɫ", -- an jî /lˤ/; bi erebî (ɫ)
-- ["ڕ"] = "r" bi erebî ()
-- Kurdiya başûr (kirmaşanî)
["ł"] = "ɫ", -- bnr. "ll"; mînak bał, diɫ
["ň"] = "ŋ", -- mînak: maň, seň
["ڕ"] = "ř", -- bnr. 'rr'; mînak: piř
["ۊ"] = "yː" -- mînak: tü
}
-- Jihevqetandin
local vowels = "ا ە ێ ی ۆ و وو"
local vowel = "[" .. vowels .. "]"
local consonant = "[^" .. vowels .. ". -]"
local syllabify_pattern = "(" .. vowel .. ")(" .. consonant .. "?)(" .. consonant .. "?)(" .. vowel .. ")"
local function syllabify(word)
word = mw.ustring.gsub(word, "%-(" .. consonant .. ")%-(" .. consonant .. ")", "%1.%2")
word = string.gsub(word, "%-", ".")
-- Add syllable breaks.
for count = 1, 2 do
word = mw.ustring.gsub(
word,
syllabify_pattern,
function(a, b, c, d)
if c == "" and b ~= "" then
c, b = b, ""
end
return a .. b .. "." .. c .. d
end
)
end
word = mw.ustring.gsub(word, '([aeêiîouûy])([^aeêiîouûy. ])([^aeêiîouûy. ])([^aeêiîouûy. ])', "%1%2%3.%4")
return word
end
function export.phonemic(word)
word = mw.ustring.lower(word) -- nivîsa biçûk
word = syllabify(word)
word = mw.ustring.gsub(word, '.', letters1_phonemes)
word = mw.ustring.gsub(word,'xw','xʷ') -- mînak: maň, seň
word = mw.ustring.gsub(word,'nɡ','ŋɡ') -- minak: ferheng
word = mw.ustring.gsub(word,'nk','ŋk') -- minak: bank
word = mw.ustring.gsub(word, '^ɾ', "r") -- mînak: roj
word = mw.ustring.gsub(word,'ɾɾ','r') -- mînak: pirr; bi erebî (ڕ)
word = mw.ustring.gsub(word, 'll', 'ɫ') -- an jî /lˁ/; mînak: bi soranî gull (گوڵ) (bi kurmancî gul); bi erebî (ڵ)
word = mw.ustring.gsub(word,'ɘj','iː') -- iy → îy
word = mw.ustring.gsub(word,'وو','u:') -- mînak: maň, سوو
-- + Giranî (stress) li ser kîteya dawî
tab_word = mw.text.split(word, '%.')
if (#tab_word ~= 1) then
tab_word[#tab_word] = "ˈ" .. tab_word[#tab_word]
end
word = table.concat(tab_word, '')
ipa = word
-- Add default stress mark if not present
if not mw.ustring.find(ipa, "") then
ipa = "" .. ipa
end
return ipa
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