Module:car-IPA

local export = {} local PAGENAME = mw.title.getCurrentTitle.text

local m_IPA = require("Module:IPA") local m_a = require("Module:accent qualifier") local lang = require("Module:languages").getByCode("car")

-- single characters that map to IPA sounds local phonetic_chars_map = { ["a"] = "a", ["à"] = "aʔ", ["á"] = "aː", ["â"] = "aːʔ", ["e"] = "e", ["è"] = "eʔ", ["é"] = "eː", ["ê"] = "eːʔ", ["i"] = "i", ["ì"] = "iʔ", ["í"] = "iː", ["î"] = "iːʔ", ["j"] = "j", ["k"] = "k", ["`"] = "ʔ", ["m"] = "m", ["n"] = "n", ["o"] = "o", ["ò"] = "oʔ", ["ó"] = "oː", ["ô"] = "oːʔ", ["p"] = "p", ["r"] = "ɽ", ["s"] = "s", ["t"] = "t", ["u"] = "u", ["ù"] = "uʔ", ["ú"] = "uː", ["û"] = "uːʔ", ["w"] = "w", ["y"] = "ɨ", ["ỳ"] = "ɨʔ", ["ý"] = "ɨː", ["ŷ"] = "ɨːʔ", ["b"] = "b", ["d"] = "d", ["f"] = "f", ["g"] = "ɡ", }

-- character sequences of two that map to IPA sounds local phonetic_2chars_map = { ["sj"] = "ʃ", }

function export.to_base_IPA(word) word = mw.ustring.lower(word)

local phonetic = word

for pat, repl in pairs(phonetic_2chars_map) do		phonetic = phonetic:gsub(pat, repl) end

phonetic = mw.ustring.gsub(phonetic, '.', phonetic_chars_map)

-- unwritten glottal stop phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ]ː?)([aeiouɨ]ː?)ʔ", "%1ʔ%2ʔ")

-- vowel lengthening/stress phonetic = mw.ustring.gsub(phonetic, "[mn]([ptkbdɡfsʃmnɽjw])", "N%1") phonetic = mw.ustring.gsub(phonetic, "[mn]%f[%A]", "N") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])i", "%1J") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])ɨ", "%1Y") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])u", "%1W") phonetic = mw.ustring.gsub(phonetic, "%f[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N?p?t?k?b?d?ɡ?f?s?ʃ?m?n?ɽ?j?w?[aeiouɨ]ʔ?J?Y?W?N?p?t?k?b?d?ɡ?f?s?ʃ?m?n?ɽ?j?w?[aeiouɨ])([^ː])", "ː%1ː%2") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])ː([ʔJYWN])", "%1%2") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])ː%f[%A]", "%1") phonetic = mw.ustring.gsub(phonetic, "J", "i") phonetic = mw.ustring.gsub(phonetic, "Y", "ɨ") phonetic = mw.ustring.gsub(phonetic, "W", "u")

-- palatalization phonetic = mw.ustring.gsub(phonetic, "(iː?ʔ?N?)p([^i])", "%1pʲ%2") phonetic = mw.ustring.gsub(phonetic, "(iː?ʔ?N?)t([^i])", "%1tʲ%2") phonetic = mw.ustring.gsub(phonetic, "(iː?ʔ?N?)k([^i])", "%1kʲ%2") phonetic = mw.ustring.gsub(phonetic, "(iː?ʔ?N?)b([^i])", "%1bʲ%2") phonetic = mw.ustring.gsub(phonetic, "(iː?ʔ?N?)d([^i])", "%1dʲ%2") phonetic = mw.ustring.gsub(phonetic, "(iː?ʔ?N?)ɡ([^i])", "%1ɡʲ%2") phonetic = mw.ustring.gsub(phonetic, "(iː?ʔ?N?)s([^i])", "%1ʃ%2") phonetic = mw.ustring.gsub(phonetic, "si", "ʃi") phonetic = mw.ustring.gsub(phonetic, "(iː?ʔ?N?)ʃi", "%1si") phonetic = mw.ustring.gsub(phonetic, "([ie]ː?ʔ?N?)ɽ", "%1ɾ") phonetic = mw.ustring.gsub(phonetic, "(iː?ʔ?N?)m([^i])", "%1mʲ%2") phonetic = mw.ustring.gsub(phonetic, "(iː?ʔ?N?)n([^i])", "%1ɲ%2")

-- glottal allophones phonetic = mw.ustring.gsub(phonetic, "ʔ([ptkfsʃ])", "h%1")

-- nasals phonetic = mw.ustring.gsub(phonetic, "N([ɲj])", "ɲ%1") phonetic = mw.ustring.gsub(phonetic, "N([kɡw])", "ŋ%1") phonetic = mw.ustring.gsub(phonetic, "N([pbfm])", "m%1") phonetic = mw.ustring.gsub(phonetic, "N([tdsʃn])", "n%1") -- not sure about s/ʃ, they might require ŋ rather than n	phonetic = mw.ustring.gsub(phonetic, "N[ɽɾ]", "n") phonetic = mw.ustring.gsub(phonetic, "aN%f[%A]", "ã") phonetic = mw.ustring.gsub(phonetic, "eN%f[%A]", "ẽ") phonetic = mw.ustring.gsub(phonetic, "iN%f[%A]", "iɲ") phonetic = mw.ustring.gsub(phonetic, "oN%f[%A]", "õ") phonetic = mw.ustring.gsub(phonetic, "uN%f[%A]", "ũ") phonetic = mw.ustring.gsub(phonetic, "ɨN%f[%A]", "ɨ̃") phonetic = mw.ustring.gsub(phonetic, "N", "ŋ")

return phonetic end

function export.finalize_IPA(word) local phonetic = word

-- diphthong offglides phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])i", "%1j") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])ɨ", "%1ɰ") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])u", "%1w")

-- unpronounced/indistinct w and j in certain environments phonetic = mw.ustring.gsub(phonetic, "(.)[wʋβ]u", "%1u") phonetic = mw.ustring.gsub(phonetic, "([oa]ː?)[jð]e", "%1e")

-- notation phonetic = mw.ustring.gsub(phonetic, "ɽ", "ɺ̢")

return phonetic end

function export.to_IPA(word) local phonetic = export.to_base_IPA(word)

-- non-phonemic vowel loss phonetic = mw.ustring.gsub(phonetic, "%f[%a]ɨ([^ː])", "%1") phonetic = mw.ustring.gsub(phonetic, "%f[%a]i([^ːɾ])", "%1") phonetic = mw.ustring.gsub(phonetic, "m([uɨ])%f[%A]", "m(%1)")

phonetic = export.finalize_IPA(phonetic)

return "[" .. phonetic .. "]" end

function export.to_Venezuelan_IPA(word) local phonetic = word

-- basic phonetic differences phonetic = mw.ustring.gsub(phonetic, "j", "ð") phonetic = mw.ustring.gsub(phonetic, "w", "β")

-- palatalization phonetic = mw.ustring.gsub(phonetic, "tʲ", "tʃ") phonetic = mw.ustring.gsub(phonetic, "ŋkʲ", "nʃ") phonetic = mw.ustring.gsub(phonetic, "kʲ", "ʃ") phonetic = mw.ustring.gsub(phonetic, "(iː?ʔ?h?)ɾ([^i])", "%1j%2") phonetic = mw.ustring.gsub(phonetic, "(iː?ʔ?h?ɲ?)ð([^i])", "%1j%2") phonetic = mw.ustring.gsub(phonetic, "(iː?ʔ?h?ŋ?)β([^i])", "%1βʲ%2")

-- fleeting ɰ/u phonetic = mw.ustring.gsub(phonetic, "([ɨu]ː?m?[pb])([^ɨu])", "%1w%2") phonetic = mw.ustring.gsub(phonetic, "(ɨː?ʔ?m?)m([^ɨupbm])", "%1mɰ%2") phonetic = mw.ustring.gsub(phonetic, "(uː?ʔ?m?)m([^ɨupbm])", "%1mw%2") phonetic = mw.ustring.gsub(phonetic, "%f[%a](ɨː?ʔ?h?n?ŋ?[tkdɡsnɽð])([^ɨu])", "%1ɰ%2") phonetic = mw.ustring.gsub(phonetic, "(ɨː?ʔ?)ɽ([a][^ʔ])", "%1ɽɰ%2") -- not fully accurate; I haven’t succeeded in determining the full conditions of the actual rule phonetic = mw.ustring.gsub(phonetic, "(ɨː?ʔ?)ɽã", "%1ɽɰã") -- continued phonetic = mw.ustring.gsub(phonetic, "([ɨu]ː?ʔ?m?n?ɲ?ŋ?)β([^ɨu])", "%1w%2")

-- nasals phonetic = mw.ustring.gsub(phonetic, "ɲ[jð]", "ɲɲ")

-- coalescence phonetic = mw.ustring.gsub(phonetic, "hpʲ?", "h") phonetic = mw.ustring.gsub(phonetic, "ɨi%f[%A]", "i")

-- non-phonemic vowel loss phonetic = mw.ustring.gsub(phonetic, "%f[%a]ɨ([^ː])", "%1") phonetic = mw.ustring.gsub(phonetic, "%f[%a]i([^ː])", "%1") phonetic = mw.ustring.gsub(phonetic, "m([uɨ])%f[%A]", "m(%1)")

-- different treatment of long high vowels phonetic = mw.ustring.gsub(phonetic, "([iɨu])ːp", "%1pp") phonetic = mw.ustring.gsub(phonetic, "([iɨu])ːt", "%1tt") phonetic = mw.ustring.gsub(phonetic, "([iɨu])ːtʃ", "%1ttʃ") phonetic = mw.ustring.gsub(phonetic, "([iɨu])ːk", "%1kk") phonetic = mw.ustring.gsub(phonetic, "([iɨu])ːb", "%1bb") phonetic = mw.ustring.gsub(phonetic, "([iɨu])ːd", "%1dd") phonetic = mw.ustring.gsub(phonetic, "([iɨu])ːɡ", "%1ɡɡ") phonetic = mw.ustring.gsub(phonetic, "([iɨu])ːf", "%1hf") phonetic = mw.ustring.gsub(phonetic, "([iɨu])ːs", "%1hs") phonetic = mw.ustring.gsub(phonetic, "([iɨu])ːʃ", "%1hʃ") phonetic = mw.ustring.gsub(phonetic, "([iɨu])ːm", "%1mm") phonetic = mw.ustring.gsub(phonetic, "([iɨu])ːn", "%1nn") phonetic = mw.ustring.gsub(phonetic, "([iɨu])ːɲ", "%1ɲɲ") phonetic = mw.ustring.gsub(phonetic, "([iɨu])ːŋ", "%1ŋŋ") phonetic = mw.ustring.gsub(phonetic, "([iɨu])ːj", "%1jj") phonetic = mw.ustring.gsub(phonetic, "([iɨu])ːð", "%1ðð") phonetic = mw.ustring.gsub(phonetic, "([iɨu])ːw", "%1ww") phonetic = mw.ustring.gsub(phonetic, "([iɨu])ːβ", "%1ββ")

-- coalescence of palatalizing diphthongs phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])ipʲ", "%1ppʲ") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])itʃ", "%1ttʃ") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])iʃ", "%1hʃ") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])ibʲ", "%1bbʲ") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])idʲ", "%1ddʲ") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])iɡʲ", "%1ɡɡʲ") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])imʲ", "%1mmʲ") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])iɲ", "%1ɲɲ") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])ij", "%1jj")

phonetic = export.finalize_IPA(phonetic)

return "[" .. phonetic .. "]" end

function export.to_West_Surinamese_IPA(word) local phonetic = word

-- voicing phonetic = mw.ustring.gsub(phonetic, "([mnɲŋ])p", "%1b") phonetic = mw.ustring.gsub(phonetic, "([mnɲŋ])t", "%1d") phonetic = mw.ustring.gsub(phonetic, "([mnɲŋ])k", "%1ɡ")

-- palatalization phonetic = mw.ustring.gsub(phonetic, "kʲ", "c") phonetic = mw.ustring.gsub(phonetic, "ŋɡʲ", "ɲɟ") phonetic = mw.ustring.gsub(phonetic, "ɡʲ", "ɟ") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ]i)ɲ([aeiouɨãẽĩõũɨ̃])", "%1j%2") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ]i)ɾ([^i])", "%1dʝ%2") phonetic = mw.ustring.gsub(phonetic, "%f[%a](iː?ʔ?h?)ɾ([^i])", "%1dʝ%2") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ]i)j([^i])", "%1ʝ%2") phonetic = mw.ustring.gsub(phonetic, "%f[%a](iː?ʔ?h?ɲ?)j([^i])", "%1ʝ%2") phonetic = mw.ustring.gsub(phonetic, "(iː?ʔ?h?ŋ?)w([^i])", "%1ɥ%2")

-- allophone of w	phonetic = mw.ustring.gsub(phonetic, "w", "ʋ") phonetic = mw.ustring.gsub(phonetic, "(uː?ʔ?h?ŋ?)ʋ", "%1w")

-- nasals phonetic = mw.ustring.gsub(phonetic, "ɲ[jʝ]", "jj")

-- non-phonemic vowel loss phonetic = mw.ustring.gsub(phonetic, "%f[%a]ɨ([^ː])", "%1") phonetic = mw.ustring.gsub(phonetic, "%f[%a]i([^ːɾd])", "%1") phonetic = mw.ustring.gsub(phonetic, "m([uɨ])%f[%A]", "m(%1)")

phonetic = export.finalize_IPA(phonetic)

return "[" .. phonetic .. "]" end

function export.to_East_Surinamese_IPA(word) local phonetic = word

-- palatalization phonetic = mw.ustring.gsub(phonetic, "tʲ", "c") phonetic = mw.ustring.gsub(phonetic, "kʲ", "c") phonetic = mw.ustring.gsub(phonetic, "dʲ", "ɟ") phonetic = mw.ustring.gsub(phonetic, "ɡʲ", "ɟ") phonetic = mw.ustring.gsub(phonetic, "ŋ([cɟ])", "ɲ%1")

-- voicing phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])i", "%1J") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])ɨ", "%1Y") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])u", "%1W") phonetic = mw.ustring.gsub(phonetic, "([maeiouɨ])p", "%1b") phonetic = mw.ustring.gsub(phonetic, "([naeiouɨ])t", "%1d") phonetic = mw.ustring.gsub(phonetic, "([ɲaeiouɨ])c", "%1ɟ") phonetic = mw.ustring.gsub(phonetic, "([ŋaeiouɨ])k", "%1ɡ") phonetic = mw.ustring.gsub(phonetic, "J", "i") phonetic = mw.ustring.gsub(phonetic, "Y", "ɨ") phonetic = mw.ustring.gsub(phonetic, "W", "u")

-- nasals phonetic = mw.ustring.gsub(phonetic, "ɲj", "jj")

-- coalescence phonetic = mw.ustring.gsub(phonetic, "%f[%a]ʃiʃ", "ʃː") phonetic = mw.ustring.gsub(phonetic, "%f[%a]ʃi([^ːɾ])", "ʃ%1") phonetic = mw.ustring.gsub(phonetic, "ʃb", "ʃp") phonetic = mw.ustring.gsub(phonetic, "ʃd", "ʃt") phonetic = mw.ustring.gsub(phonetic, "ʃɟ", "ʃc") phonetic = mw.ustring.gsub(phonetic, "ʃɡ", "ʃk")

-- non-phonemic vowel loss phonetic = mw.ustring.gsub(phonetic, "%f[%a]ɨ([^ː])", "%1") phonetic = mw.ustring.gsub(phonetic, "%f[%a]i([^ːɾ])", "%1") phonetic = mw.ustring.gsub(phonetic, "m([uɨ])%f[%A]", "m(%1)") phonetic = mw.ustring.gsub(phonetic, "([pbm]ɨʔ?h?)([pbm])", "(%1)%2") phonetic = mw.ustring.gsub(phonetic, "%(m", "m(")

-- different treatment of stressed vowels and diphthongs before plosives phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])ːp", "%1ʔp") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])ːt", "%1ʔt") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])ːc", "%1ʔc") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])ːk", "%1ʔk") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])ːb", "%1ʔb") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])ːd", "%1ʔd") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])ːɟ", "%1ʔɟ") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ])ːɡ", "%1ʔɡ") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ][iɨu])p", "%1hp") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ][iɨu])t", "%1ht") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ][iɨu])c", "%1hc") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ][iɨu])k", "%1hk") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ][iɨu])b", "%1hb") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ][iɨu])d", "%1hd") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ][iɨu])ɟ", "%1hɟ") phonetic = mw.ustring.gsub(phonetic, "([aeiouɨ][iɨu])ɡ", "%1hɡ")

phonetic = export.finalize_IPA(phonetic)

return "[" .. phonetic .. "]" end

function export.pronunciation(word) local parent_args = word:getParent.args

if type(word) == "table" then word = word.args[1] or word:getParent.args[1] end if not word or (word == "") then word = PAGENAME end

local generate_ven = true local generate_wsur = true local generate_esur = true if parent_args['v'] == '0' then generate_ven = false end if parent_args['w'] == '0' then generate_wsur = false end if parent_args['e'] == '0' then generate_esur = false end

local final_text = "" local base_IPA = export.to_base_IPA(word)

if generate_ven then local items = {} table.insert(items, {pron = export.to_Venezuelan_IPA(base_IPA), note = nil}) ven = m_IPA.format_IPA_full { lang = lang, items = items }

final_text = final_text .. "* " .. m_a.format_qualifiers(lang, {"Venezuela"}) .. " " .. ven if generate_wsur or generate_esur then final_text = final_text .. "\n" end end

if generate_wsur then local items = {} table.insert(items, {pron = export.to_West_Surinamese_IPA(base_IPA), note = nil}) wsur = m_IPA.format_IPA_full { lang = lang, items = items }

final_text = final_text .. "* " .. m_a.format_qualifiers(lang, {"West Suriname"}) .. " " .. wsur if generate_esur then final_text = final_text .. "\n" end end

if generate_esur then local items = {} table.insert(items, {pron = export.to_East_Surinamese_IPA(base_IPA), note = nil}) esur = m_IPA.format_IPA_full { lang = lang, items = items }

final_text = final_text .. "* " .. m_a.format_qualifiers(lang, {"East Suriname"}) .. " " .. esur end

if generate_wsur and generate_esur and (wsur == esur) then if generate_ven then if ven == wsur then final_text = "* " .. ven else final_text = "* " .. m_a.format_qualifiers(lang, {"Venezuela"}) .. " " .. ven .. "\n* " .. m_a.format_qualifiers(lang, {"Suriname"}) .. " " .. wsur end else final_text = "* " .. m_a.format_qualifiers(lang, {"Suriname"}) .. " " .. wsur end else if generate_wsur and generate_ven and (wsur == ven) then if generate_esur then final_text = "* " .. m_a.format_qualifiers(lang, {"Venezuela", "West Suriname"}) .. " " .. ven .. "\n* " .. m_a.format_qualifiers(lang, {"East Suriname"}) .. " " .. esur else final_text = "* " .. m_a.format_qualifiers(lang, {"Venezuela", "West Suriname"}) .. " " .. ven end end end

return final_text end

return export