Module:tzm-IPA/sandbox

local export = {} local s = mw.ustring.gsub local c = { ["g"] = "ɡ", ["ḍ"] = "dˤ", ["š"] = "ʃ", ["j"] = "ʒ", ["y"] = "j", ["ẓ"] = "zˤ", ["ṛ"] = "rˤ", ["ṣ"] = "sˤ", ["ṭ"] = "tˤ", ["ḥ"] = "ħ", ["ɛ"] = "ʕ", ["e"] = "ə" } local p = { ["ɣ"] = "ʁ", ["ɡʷ"] = "ɣʷ", ["tˤ"] = "Tˤ", ["x"] = "χ", ["kʷ"] = "xʷ", ["a"] = "æ", ["ɡ"] = "ʝ", ["d"] = "ð", ["dˤ"] = "ðˤ", ["k"] = "ç", ["n"] = "N", ["t"] = "θ", ["b"] = "β" } local t = { ["ʝ"] = "ɟː", ["ð"] = "Dː", ["ðˤ"] = "Tˤː", ["f"] = "fː", ["ʁ"] = "qː", ["ç"] = "cː", ["l"] = "lː", ["m"] = "mː", ["N"] = "Nː", ["r"] = "rː", ["s"] = "sː", ["ʃ"] = "t͡ʃː", ["θ"] = "Tː", ["w"] = "ɡʷː", ["j"] = "ɟː", ["z"] = "zː", ["zˤ"] = "zˤː", ["β"] = "bː", ["χ"] = "χː", ["ʒ"] = "d͡ʒː", ["ɣʷ"] = "ɡʷː", ["rˤ"] = "rˤː", ["ħ"] = "ħː", ["ʕ"] = "ʕː", ["xʷ"] = "kʷː" } local C = "[ɡɟʝDdðfɣʁkcçlmNnrsʃTtθwjzbβhxχʒqħʕ]" local V = "[aiuəæɑ]" local r = { ["a"] = { ["^(" .. C .. "[ˤʷ]?ː?" .. C .. "?[ˤʷ]?" .. V .. ")ʝ(" .. V .. C .. "?[ˤʷ]?)$"] = "%1jː%2", ["^(" .. C .. "[ˤʷ]?ː?" .. C .. "?[ˤʷ]?" .. V .. ")ɣʷ(" .. V .. C .. "?[ˤʷ]?)$"] = "%1wː%2", ["^(" .. C .. "[ˤʷ]?ː?" .. C .. "?[ˤʷ]?" .. V .. ")ʁ(" .. V .. C .. "?[ˤʷ]?)$"] = "%1ʁː%2", ["^(" .. C .. "[ˤʷ]?ː?" .. C .. "?[ˤʷ]?" .. V .. ")ʝ(" .. V .. C .. "?[ˤʷ]?[‿ ])"] = "%1jː%2", ["^(" .. C .. "[ˤʷ]?ː?" .. C .. "?[ˤʷ]?" .. V .. ")ɣʷ(" .. V .. C .. "?[ˤʷ]?[‿ ])"] = "%1wː%2", ["^(" .. C .. "[ˤʷ]?ː?" .. C .. "?[ˤʷ]?" .. V .. ")ʁ(" .. V .. C .. "?[ˤʷ]?[‿ ])"] = "%1ʁː%2", ["([‿ ]ə?" .. C .. "[ˤʷ]?ː?" .. C .. "?[ˤʷ]?" .. V .. ")ʝ(" .. V .. C .. "?[ˤʷ]?)$"] = "%1jː%2", ["([‿ ]ə?" .. C .. "[ˤʷ]?ː?" .. C .. "?[ˤʷ]?" .. V .. ")ɣʷ(" .. V .. C .. "?[ˤʷ]?)$"] = "%1wː%2", ["([‿ ]ə?" .. C .. "[ˤʷ]?ː?" .. C .. "?[ˤʷ]?" .. V .. ")ʁ(" .. V .. C .. "?[ˤʷ]?)$"] = "%1ʁː%2", ["([‿ ]ə?" .. C .. "[ˤʷ]?ː?" .. C .. "?[ˤʷ]?" .. V .. ")ʝ(" .. V .. C .. "?[ˤʷ]?[‿ ])"] = "%1jː%2", ["([‿ ]ə?" .. C .. "[ˤʷ]?ː?" .. C .. "?[ˤʷ]?" .. V .. ")ɣʷ(" .. V .. C .. "?[ˤʷ]?[‿ ])"] = "%1wː%2", ["([‿ ]ə?" .. C .. "[ˤʷ]?ː?" .. C .. "?[ˤʷ]?" .. V .. ")ʁ(" .. V .. C .. "?[ˤʷ]?[‿ ])"] = "%1ʁː%2" },   ["b"] = { ["(" .. C .. "ˤ" .. V .. "?[dtzrs])([^ˤ])"] = "%1ˤ%2", ["(" .. C .. "ˤ" .. V .. "?[dtzrs])$"] = "%1ˤ", ["([dtzrs])(" .. C .. "ˤ)"] = "%1ˤ%2" },   ["c"] = { ["f([‿ ]?[βðd̪zʒʝɟɣɡʁʕ])"] = "β%1", ["θ(ˤ?[‿ ]?[βðd̪zʒʝɟɣɡʁʕ])"] = "ð%1", ["T(ˤ?[‿ ]?[βðd̪zʒʝɟɣɡʁʕ])"] = "D%1", ["s(ˤ?[‿ ]?[βðd̪zʒʝɟɣɡʁʕ])"] = "z%1", ["ʃ([‿ ]?[βðd̪zʒʝɟɣɡʁʕ])"] = "ʒ%1", ["ç([‿ ]?[βðd̪zʒʝɟɣɡʁʕ])"] = "ʝ%1", ["c([‿ ]?[βðd̪zʒʝɟɣɡʁʕ])"] = "ɟ%1", ["x(ʷ[‿ ]?[βðd̪zʒʝɟɣɡʁʕ])"] = "ɣ%1", ["k(ʷ[‿ ]?[βðd̪zʒʝɟɣɡʁʕ])"] = "ɡ%1", ["χ([‿ ]?[βðd̪zʒʝɟɣɡʁʕ])"] = "ʁ%1", ["ħ([‿ ]?[βðd̪zʒʝɟɣɡʁʕ])"] = "ʕ%1", ["β([‿ ]?[fθt̪sʃçcxkχħ])"] = "f%1", ["ð(ˤ?[‿ ]?[fθt̪sʃçcxkχħ])"] = "θ%1", ["D(ˤ?[‿ ]?[fθt̪sʃçcxkχħ])"] = "T%1", ["z(ˤ?[‿ ]?[fθt̪sʃçcxkχħ])"] = "s%1", ["ʒ([‿ ]?[fθt̪sʃçcxkχħ])"] = "ʃ%1", ["ʝ([‿ ]?[fθt̪sʃçcxkχħ])"] = "ç%1", ["ɟ([‿ ]?[fθt̪sʃçcxkχħ])"] = "c%1", ["ɣ(ʷ[‿ ]?[fθt̪sʃçcxkχħ])"] = "x%1", ["ɡ(ʷ[‿ ]?[fθt̪sʃçcxkχħ])"] = "k%1", ["ʁ([‿ ]?[fθt̪sʃçcxkχħ])"] = "χ%1", ["ʕ([‿ ]?[fθt̪sʃçcxkχħ])"] = "ħ%1" },   ["d"] = { ["([^fb])[fb]( ?)([fb])([^fb])"] = "%1%3%2%3%4", ["^[fb]( ?)([fb])([^fb])"] = "%2%1%2%3", ["([^fb])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]( ?)([ħʕ])$"] = "%1%3%2%3" },   ["e"] = { ["θ([‿ ]?[szʃʒ])"] = "T%1", ["ð([‿ ]?[szʃʒ])"] = "D%1" },   ["f"] = {["([rl])( ?)n"] = "%1%2%1"}, ["g"] = { ["nll?"] = "ll", ["n ll?"] = "l l", ["nrr?"] = "rr", ["n rr?"] = "r r"   }, ["h"] = {["j( ?)w"] = "ɡʷ%1ɡʷ"}, ["i"] = { ["^j(" .. C .. ")"] = "i%1", ["([‿ ])j(" .. C .. ")"] = "%1i%2", ["^w(" .. C .. ")"] = "u%1", ["([‿ ])w(" .. C .. ")"] = "%1u%2" },   ["j"] = { ["^([smT])ː"] = "%1", ["([‿ ])ə([smT])ː"] = "%1%2" },   ["k"] = { ["(" .. C .. "[ˤʷ]?)(ː)([‿ ])"] = "%1(%2)%3", ["(" .. C .. "[ˤʷ]?)(ː)$"] = "%1(%2)" },   ["l"] = { ["([ħʕχqʁˤ]ː?)æ"] = "%1ɑ", ["([ħʕχqʁˤ]ː?)i"] = "%1ɪ̙", ["([ħʕχqʁˤ]ː?)u"] = "%1ʊ̙", ["æ([ħʕχqʁ])"] = "ɑ%1", ["i([ħʕχqʁ])"] = "ɪ̙%1", ["u([ħʕχqʁ])"] = "ʊ̙%1", ["æ([ðDTzrs]ˤ)"] = "ɑ%1", ["i([ðDTzrs]ˤ)"] = "ɪ̙%1", ["u([ðDTzrs]ˤ)"] = "ʊ̙%1" },   ["m"] = { ["æ(" .. C .. "[ˤʷ]?ː)"] = "æ̝%1", ["i(" .. C .. "[ˤʷ]?ː)"] = "i̞%1", ["u(" .. C .. "[ˤʷ]?ː)"] = "u̞%1", ["ɑ(" .. C .. "[ˤʷ]?ː)"] = "ɑ̝%1", ["ɪ̙(" .. C .. "[ˤʷ]?ː)"] = "ɪ̙̞%1", ["ʊ̙(" .. C .. "[ˤʷ]?ː)"] = "ʊ̙̞%1", ["æ(" .. C .. "[ˤʷ]?" .. C .. "[ˤʷ]?)"] = "æ̝%1", ["i(" .. C .. "[ˤʷ]?" .. C .. "[ˤʷ]?)"] = "i̞%1", ["u(" .. C .. "[ˤʷ]?" .. C .. "[ˤʷ]?)"] = "u̞%1", ["ɑ(" .. C .. "[ˤʷ]?" .. C .. "[ˤʷ]?)"] = "ɑ̝%1", ["ɪ̙(" .. C .. "[ˤʷ]?" .. C .. "[ˤʷ]?)"] = "ɪ̙̞%1", ["ʊ̙(" .. C .. "[ˤʷ]?" .. C .. "[ˤʷ]?)"] = "ʊ̙̞%1", ["æ(" .. C .. "[ˤʷ]?)$"] = "æ̝%1", ["i(" .. C .. "[ˤʷ]?)$"] = "i̞%1", ["u(" .. C .. "[ˤʷ]?)$"] = "u̞%1", ["ɑ(" .. C .. "[ˤʷ]?)$"] = "ɑ̝%1", ["ɪ̙(" .. C .. "[ˤʷ]?)$"] = "ɪ̙̞%1", ["ʊ̙(" .. C .. "[ˤʷ]?)$"] = "ʊ̙̞%1", ["æ(" .. C .. "[ˤʷ]?[‿ ])"] = "æ̝%1", ["i(" .. C .. "[ˤʷ]?[‿ ])"] = "i̞%1", ["u(" .. C .. "[ˤʷ]?[‿ ])"] = "u̞%1", ["ɑ(" .. C .. "[ˤʷ]?[‿ ])"] = "ɑ̝%1", ["ɪ̙(" .. C .. "[ˤʷ]?[‿ ])"] = "ɪ̙̞%1", ["ʊ̙(" .. C .. "[ˤʷ]?[‿ ])"] = "ʊ̙̞%1" },   ["n"] = {["æ$"] = "ɑ", ["æ([‿ ])"] = "ɑ%1"}, ["o"] = { ["(" .. C .. "[ˤʷ]?ː?[‿ ]?" .. C .. "[ˤʷ]?[‿ ]?)(" .. C .. "[ˤʷ]?)$"] = "%1ə%2", ["(" .. C .. "[ˤʷ]?ː?[‿ ]?" .. C .. "[ˤʷ]?[‿ ]?)(" .. C .. "[ˤʷ]?[‿ ])"] = "%1ə%2", ["^(" .. C .. "[ˤʷ]?)$"] = "ə%1" },   ["O"] = { ["(" .. C .. "[ˤʷ]?ː?[‿ ]?)(" .. C .. "[ˤʷ]?" .. C .. "[ˤʷ]?" .. V .. ")"] = "%1ə%2", ["(" .. C .. "[ˤʷ]?ː?[‿ ]?)(" .. C .. "[ˤʷ]?ː" .. C .. "?[ˤʷ]?" .. V .. ")"] = "%1ə%2" },   ["p"] = { ["əm"] = "m̩", ["əN"] = "n̪̩", ["əl"] = "l̩", ["ər"] = "r̩" },   ["q"] = { ["əj([^j])"] = "i(j)%1", ["əʝ([^ʷʝ])"] = "i(ʝ)%1", ["əw([^w])"] = "u(w)%1", ["əj$"] = "i(j)", ["əʝ$"] = "i(ʝ)", ["əw$"] = "u(w)" },   ["r"] = { ["ai(" .. C .. "[ˤʷ]?" .. C .. "?[ˤʷ]?" .. C .. "?[ˤʷ]?" .. V .. "?)$"] = "ɑ%1", ["ai(" .. C .. "[ˤʷ]?" .. C .. "?[ˤʷ]?" .. C .. "?[ˤʷ]?" .. V .. "?[‿ ])"] = "ɑ%1", ["i(" .. V .. C .. "[ˤʷ]?" .. C .. "?[ˤʷ]?" .. C .. "?[ˤʷ]?" .. V .. "?)$"] = "(ij)%1", ["i(" .. V .. C .. "[ˤʷ]?" .. C .. "?[ˤʷ]?" .. C .. "?[ˤʷ]?" .. V .. "?[‿ ])"] = "(ij)%1", ["ui(" .. C .. "[ˤʷ]?" .. C .. "?[ˤʷ]?" .. C .. "?[ˤʷ]?" .. V .. "?)$"] = "u%1", ["ui(" .. C .. "[ˤʷ]?" .. C .. "?[ˤʷ]?" .. C .. "?[ˤʷ]?" .. V .. "?[‿ ])"] = "u%1", ["u(a" .. C .. "[ˤʷ]?" .. C .. "?[ˤʷ]?" .. C .. "?[ˤʷ]?" .. V .. "?)$"] = "uj%1", ["u(a" .. C .. "[ˤʷ]?" .. C .. "?[ˤʷ]?" .. C .. "?[ˤʷ]?" .. V .. "?[‿ ])"] = "uj%1", ["a(a" .. C .. "[ˤʷ]?" .. C .. "?[ˤʷ]?" .. C .. "?[ˤʷ]?" .. V .. "?)$"] = "(ɑj)%1", ["a(a" .. C .. "[ˤʷ]?" .. C .. "?[ˤʷ]?" .. C .. "?[ˤʷ]?" .. V .. "?[‿ ])"] = "(ɑj)%1" },   ["s"] = {["([ ‿]" .. C .. "?[ˤʷ]?" .. C .. "[ˤʷ]?" .. C .. "[ˤʷ]?)a a"] = "%1‿a", ["^(" .. C .. "?[ˤʷ]?" .. C .. "[ˤʷ]?" .. C .. "[ˤʷ]?)a a"] = "%1‿a"}, ["t"] = {["([æiu]) ([æiu])"] = "%1‿j%2"}, ["T"] = {["([æiu]‿j)i"] = "%1"}, ["u"] = {["kkʷ"] = "kʷkʷ", ["ɡɡʷ"] = "ɡʷɡʷ"} } --[=[ metachanges to the rules from the normal module: --]=] --[=[local o = { {       "Ayt Ndhir", { {               {"v", "h", "r", "s", "i", "d", "f", "g", "b"}, {true, "o"}, {"q", "t", "n", "e"} },       }    } }--]=] local o = { {       {"u", "h", "r", "s", "i", "d", "f", "g", "b", "o"} }, {       {"O"}, {"q", "t", "T", "n", "e", "c", "j", "a", "l", "m", "k", "p"} } } --to test: p
 * removed from C (so adapt the %n)
 * [ˤʷ]? removed from C (so C .. "?" becomes C .. "?[ˤʷ]?")
 * clone the rules to distinguish end of string from word boundary, e.g. a replacement ending with ([‿ ].*)?$ gives one with $ and one with [‿ ]

function export.show(frame) local a = frame:getParent.args local tr = "" if a[1] then tr = a[1] else tr = s(require("Module:Tfng-translit").tr(mw.title.getCurrentTitle.text, "tzm", "Tfng"), '.', c)   end local f = "* " .. require("Module:IPA").format_IPA_full { lang = require("Module:languages").getByCode("tzm"), items = , }   local n = tr

for q = 1, #o[1][1] do       for x, y in pairs(r[o[1][1][q]]) do            n = s(n, x, y)        end end

n = s(n, '.[ˤʷ]?', p)   for d, g in pairs(t) do        n = s(n, d .. d, g)        n = s(n, d .. " " .. d .. "([^ː])", "‿" .. g .. "%1") n = s(n, d .. " " .. d .. "$", "‿" .. g)   end n = s(n, "‿ɡʷː", "w w")--special case

N = "" while N ~= n do       N = n        for q = 1, #o[2][1] do            for x, y in pairs(r[o[2][1][q]]) do                n = s(n, x, y)            end end end for q = 1, #o[2][2] do       for x, y in pairs(r[o[2][2][q]]) do            n = s(n, x, y)        end end

n = s(n, "T", "t̪") n = s(n, "D", "d̪") n = s(n, "N", "n̪")

local f = f .. "\n* " .. require("Module:accent_qualifier").show({"Ayt Ndhir"}) .. require("Module:IPA").format_IPA_full { lang = require("Module:languages").getByCode("tzm"), items = , }   return f end

return export