Module:tzm-IPA

From Wiktionary, the free dictionary
Jump to navigation Jump to search

This module generates the IPA phonological and phonetic transcription of Central Atlas Tamazight entries. It runs Template:tzm-IPA. If no parameter is provided, it will use the page title, else it is looked upon as a respelling. The testcases are here.

This module generates the phonology, which is the same for all Central Atlas Tamazight dialects (broad), and the phonetics, which is particular for each dialect (narrow). Currently it displays only the phonetic pronunciation for the Ayt Ndhir dialect according to Penchoen (1973).[1]

For Central Atlas Tamazight, the pronunciation is more relevant than the Tifinagh orthography because it is mainly an oral language, rarely written, whence the necessity of this module.

Below you shall find the functioning of this module.

Tifinagh and transcription[edit]

Here are the correspondences. An alternative pronunciation (a rarely used one) is next to the regular one, and in yellow if borrowed from Arabic phonology.

Phonotactics[edit]

The module gets the transcription of the entry name, then it generates the phonological transcription using columns 2 and 3 above. In order to generate the phonetic transcription from the phonological one, these sound laws are used.

Ayt Ndhir dialect[edit]

Here are the rules for the Ayt Ndhir dialect, spoken in Central Morocco.[1]

Consonants[edit]

  1. [{ʝ, ɣʷ, ʁ}] > [{jj, ww ʁʁ}] \ #(Cː)(C)V_V(C)# (medial in bisyllabic words, 2 p7)
  2. /{d, t, z, r, s}/ > /{d, t, z, r, s}ˤ/ \ Cˤ(V)_ or _Cˤ (emphatic spread, a p7)
  3. [{voicing¹}] > [{voicing²}] \ _{voicing²} (voicing regressive assimilation, b p7)
  4. /{lax, articulation pt¹, (ˤ)}( ){lax, articulation point¹, voicing², (ˤ)}/ > /{(‿)CC, articulation pt¹, voicing², (ˤ)}/ (assimilation. C¹&C², lax, same articulation pt > tense (geminated for 1st lecture), same articulation point. Voicing of C². ˤ if C¹ or C² is ˤ. c p8)
  5. /{t, d}/ > [{t̪, d̪}] \  _( ){s, z, sˤ, zˤ, ʃ, ʒ} (t, d as stops before these fricatives, voicing is done by rule 3. d p8)
  6. /n/ > /{r, l}/ \  {r, l}( )_ (assimilation /ln/>[ll], /rn/>[rr], e p8)
  7. /n/ > /{l, r}/ \  _( ){{l, ll}, {r, rr}} (regressive assimilation /nl/>[ll], /nr/>[rr], /nll/, [ll], /nrr/>[rr], f p8)
  8. /{{j( )j}, {j( )w}, {w( )w}}/ > [{{ɟ( )ɟ}, {ɡʷ( )ɡʷ}, {w( )w}}] (glide assimilation /jj/>[ɟɟ], /jw/>[ɡʷɡʷ], /ww/>[ww], g p8)
  9. /{j, w}/ > [{i, u}] \ #_C excepted for /{jj, ww}/ > tense (word initial glide conditioning, h p9)
  10. [ə{t̪ːu, sː, mː, t̪ː}] > [{t̪u, s, m, t̪}] \  #_ (grammatical tense consonants detensing, will see when in morphology section, otherwise this law is useless, i p9)
  11. [C¹ː] > [C¹(ː)] \  _# (word final tense consonants detensing in rapid speech but not in deliberate speech, j p9)

Vowels[edit]

  1. /{æ, i, u}/ > [{ɑ, ɪ̙, ʊ̙}] \ {ħ, ʕ, Cˤ, x, q, ɣ}_ or _{same consonants} (vocalic lowering and retracting (ie. pharyngeal) by contact of pharyngeal, pharyngealized (ie. emphatic) and uvular consonants, a p9)
  2. [{æ, i, u, ɑ, ɪ̙, ʊ̙}] > [{æ̝, i̞, u̞, ɑ̝, ɪ̙̞, ʊ̙̞}] \  _{tense(Cː), CC, C#} (vocalic medialization before tense consonants, true (ə-less) consonant clusters and final consonant, b p10)
  3. /a/ > [ɑ] \  _# (word final /a/ coloration, c p10)
  4. /∅/ > /ə/ \ {C, #}_{C¹C¹(C), CC, C#} (schwa phonological insertion: if there's no vowel before a tense consonant, or a cluster of a tense consonant and another consonant, or a two-consonant cluster or a final consonant, place a schwa there, d p10)
  5. [ə{m, n̪, l, r}] > [{m̩, n̪̩, l̩, r̩}] (schwa phonetic articulation: sonorants syllabification (and "consonant release"), d p10)
  6. /{əj, əɡ, əw}/ > /{i(j), i(ɡ), u(w)}/ (glides syllabification to diphthong then in rapid speech reduction to pure vowel, e p10)
  7. /{{a, i, u}i, {i, u}a, iV, aa}/ > [{{ɑ, i, u}, {i, u}ja, (ij)V, (ɑj)a}] \  _C(C)(C)(V)# (elision and hiatus rupture when the second vowel is part of a suffix : 2nd /i/ elided, /j/ before /a/ or after /i/, with possible elision if /aa/ or iV/, f p10)
  8. /a / > /‿/ \ #(C)CC_a (elision between an a-final verb and an a-initial noun, f p10)
  9. /{a, u, i} {a, u, i}/ > /{a, u, i}‿j{a, u, ∅}/ (hiatus rupture : /j/ before vowels, and /i/ elided, f p10)

References[edit]

  1. 1.0 1.1 1.2 Penchoen, Thomas G. (1973) Tamazight of the Ayt Ndhir (Afroasiatic dialects; 1)‎[1], Los Angeles: Undena Publications, →ISBN

local export = {}

local m_IPA = require("Module:IPA")
local m_scripts = require("Module:scripts")
local m_scripts_util = require("Module:script utilities")
local m_a = require("Module:accent qualifier")
local lang = require("Module:languages").getByCode("tzm")
local s = mw.ustring.gsub

local c = {
    ["g"] = "ɡ",
    ["ḍ"] = "dˤ",
    ["ḏ"] = "ð",
    ["c"] = "ʃ",
    ["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ː",
    ["ʃ"] = "Cː",
    ["θ"] = "Tː",
    ["w"] = "wː",
    ["j"] = "ɟː",
    ["z"] = "zː",
    ["zˤ"] = "zˤː",
    ["β"] = "bː",
    ["χ"] = "χː",
    ["ʒ"] = "Jː",
    ["ɣʷ"] = "ɡʷː",
    ["rˤ"] = "rˤː",
    ["sˤ"] = "sˤː",
    ["Tˤ"] = "Tˤː",
    ["q"] = "qː",
    ["ħ"] = "ħː",
    ["ʕ"] = "ʕː",
    ["xʷ"] = "kʷː"
}

local C = "[ɡɟʝDdðfɣʁkcçlmNnrsʃCTtθwjzbβhxχʒJqħʕ]"
local V = "[aiuəæɑ]"

local r = {
    ["a"] = {
        ["^(" .. C .. "?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?" .. V .. ")ʝ(" .. V .. "%(?" .. C .. "?%)?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?)$"] = "%1jː%2",
        ["^(" .. C .. "?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?" .. V .. ")ɣʷ(" .. V .. "%(?" .. C .. "?%)?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?)$"] = "%1wː%2",
        ["^(" .. C .. "?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?" .. V .. ")ʁ(" .. V .. "%(?" .. C .. "?%)?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?)$"] = "%1ʁː%2",
        ["^(" .. C .. "?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?" .. V .. ")ʝ(" .. V .. "%(?" .. C .. "?%)?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?[‿ ])"] = "%1jː%2",
        ["^(" .. C .. "?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?" .. V .. ")ɣʷ(" .. V .. "%(?" .. C .. "?%)?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?[‿ ])"] = "%1wː%2",
        ["^(" .. C .. "?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?" .. V .. ")ʁ(" .. V .. "%(?" .. C .. "?%)?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?[‿ ])"] = "%1ʁː%2",
        ["( ə?" .. C .. "?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?" .. V .. ")ʝ(" .. V .. "%(?" .. C .. "?%)?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?)$"] = "%1jː%2",
        ["( ə?" .. C .. "?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?" .. V .. ")ɣʷ(" .. V .. "%(?" .. C .. "?%)?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?)$"] = "%1wː%2",
        ["( ə?" .. C .. "?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?" .. V .. ")ʁ(" .. V .. "%(?" .. C .. "?%)?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?)$"] = "%1ʁː%2",
        ["( ə?" .. C .. "?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?" .. V .. ")ʝ(" .. V .. "%(?" .. C .. "?%)?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?[‿ ])"] = "%1jː%2",
        ["( ə?" .. C .. "?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?" .. V .. ")ɣʷ(" .. V .. "%(?" .. C .. "?%)?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?[‿ ])"] = "%1wː%2",
        ["( ə?" .. C .. "?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?" .. V .. ")ʁ(" .. V .. "%(?" .. C .. "?%)?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?[‿ ])"] = "%1ʁː%2"
    },
    ["b"] = {
        ["([dtzrs])([^ˤ%1][^ ]-ˤ)"] = "%1ˤ%2",
        ["(ˤ[^ ]-[dtzrs])([^ˤ%1])"] = "%1ˤ%2",
        ["(ˤ[^ ]-[dtzrs])$"] = "%1ˤ"
    },
    ["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",
        ["β([‿ ]?[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"
    },
    ["d"] = {
        ["([^fb])[fb]( ?)([fb])([^fb])"] = "%1%3%2%3%4",
        ["^[fb]( ?)([fb])([^fb])"] = "%2%1%2%3",
        ["([^fb])[fb]( ?)([fb])$"] = "%1%3%2%3",
        ["([^td]ˤ?)[td](ˤ?)( ?)([td])(ˤ?)([^td])"] = "%1%4%2%3%4%5%6",
        ["^[td](ˤ?)( ?)([td])(ˤ?)([^td])"] = "%3%1%2%3%4%5",
        ["([^td]ˤ?)[td](ˤ?)( ?)([td])(ˤ?)$"] = "%1%4%2%3%4%5",
        ["([^sz]ˤ?)[sz](ˤ?)( ?)([sz])(ˤ?)([^sz])"] = "%1%4%2%3%4%5%6",
        ["^[sz](ˤ?)( ?)([sz])(ˤ?)([^sz])"] = "%3%1%2%3%4%5",
        ["([^sz]ˤ?)[sz](ˤ?)( ?)([sz])(ˤ?)$"] = "%1%4%2%3%4%5",
        ["([^ʃʒ])[ʃʒ]( ?)([ʃʒ])([^ʃʒ])"] = "%1%3%2%3%4",
        ["^[ʃʒ]( ?)([ʃʒ])([^ʃʒ])"] = "%2%1%2%3",
        ["([^ʃʒ])[ʃʒ]( ?)([ʃʒ])$"] = "%1%3%2%3",
        ["([^kɡj])[kɡj]( ?)([kɡj])([kɡj]ʷ)"] = "%1%3%2%3%4",
        ["^[kɡj]( ?)([kɡj])([kɡj]ʷ)"] = "%2%1%2%3",
        ["([^kɡj])[kɡj]( ?)([kɡj])$"] = "%1%3%2%3",
        ["([^kɡj])[kɡj]( ?)([kɡj])([^ʷkɡj])"] = "%1%3%2%3%4",
        ["^[kɡj]( ?)([kɡj])([^ʷkɡj])"] = "%2%1%2%3",
        ["([^kɡj])[kɡj]( ?)([kɡj])$"] = "%1%3%2%3",
        ["([^ʷkɡw])[kɡ]ʷ( ?)([kɡ]ʷ)([^w][^ʷ])"] = "%1%3%2%3%4",
        ["([^ʷkɡw])[kɡ]ʷ( ?)([kɡ]ʷ)([^w])$"] = "%1%3%2%3%4",
        ["([^ʷkɡw])[kɡ]ʷ( ?)([kɡ]ʷ)([^w][‿ ])"] = "%1%3%2%3%4",
        ["^[kɡ]ʷ( ?)([kɡ]ʷ)([^w][^ʷ])"] = "%2%1%2%3",
        ["^[kɡ]ʷ( ?)([kɡ]ʷ)([^w])$"] = "%2%1%2%3",
        ["^[kɡ]ʷ( ?)([kɡ]ʷ)([^w][‿ ])"] = "%2%1%2%3",
        ["([^ʷkɡw])[kɡ]ʷ( ?)([kɡ]ʷ)$"] = "%1%3%2%3",
        ["([^ʷw])w( ?)([kɡ]ʷ)([^w][^ʷ])"] = "%1%3%2%3%4",
        ["([^ʷw])w( ?)([kɡ]ʷ)([^w])$"] = "%1%3%2%3%4",
        ["([^ʷw])w( ?)([kɡ]ʷ)([^w][‿ ])"] = "%1%3%2%3%4",
        ["^w( ?)([kɡ]ʷ)([^w][^ʷ])"] = "%2%1%2%3",
        ["^w( ?)([kɡ]ʷ)([^w])$"] = "%2%1%2%3",
        ["^w( ?)([kɡ]ʷ)([^w][‿ ])"] = "%2%1%2%3",
        ["([^ʷw])w( ?)([kɡ]ʷ)$"] = "%1%3%2%3",
        ["([^ʷkɡw])[kɡ]ʷ( ?)w([^w][^ʷ])"] = "%1ɡʷ%2ɡʷ%3",
        ["([^ʷkɡw])[kɡ]ʷ( ?)w([^w])$"] = "%1ɡʷ%2ɡʷ%3",
        ["([^ʷkɡw])[kɡ]ʷ( ?)w([^w][‿ ])"] = "%1ɡʷ%2ɡʷ%3",
        ["^[kɡ]ʷ( ?)w([^w][^ʷ])"] = "ɡʷ%1ɡʷ%2",
        ["^[kɡ]ʷ( ?)w([^w])$"] = "ɡʷ%1ɡʷ%2",
        ["^[kɡ]ʷ( ?)w([^w][‿ ])"] = "ɡʷ%1ɡʷ%2",
        ["([^ʷkɡw])[kɡ]ʷ( ?)w$"] = "%1ɡʷ%2ɡʷ",
        ["([^xqɣ])[xqɣ]( ?)([xqɣ])([^xqɣ])"] = "%1%3%2%3%4",
        ["^[xqɣ]( ?)([xqɣ])([^xqɣ])"] = "%2%1%2%3",
        ["([^xqɣ])[xqɣ]( ?)([xqɣ])$"] = "%1%3%2%3",
        ["([^ħʕ])[ħʕ]( ?)([ħʕ])([^ħʕ])"] = "%1%3%2%3%4",
        ["^[ħʕ]( ?)([ħʕ])([^ħʕ])"] = "%2%1%2%3",
        ["([^ħʕ])[ħʕ]( ?)([ħʕ])$"] = "%1%3%2%3"
    },
    ["e"] = {["θ([‿ ]?[szʃʒ])"] = "T%1", ["ð([‿ ]?[szʃʒ])"] = "D%1"},
    ["f"] = {
        ["([^rl])([rl])( ?)n([^t]?[‿ ])"] = "%1%2%3%2%4",
        ["([^rl])([rl])( ?)n([^t]?)$"] = "%1%2%3%2%4"
    },
    ["g"] = {["nll?"] = "ll", ["n ll?"] = "l l", ["nrr?"] = "rr", ["n rr?"] = "r r"},
    ["h"] = {["j( ?)w"] = "ɡʷ%1ɡʷ"},
    ["i"] = {
        ["^j(" .. C .. ")"] = "i%1",
        ["([^j][‿ ])j(" .. C .. ")"] = "%1i%2",
        ["^w(" .. C .. ")"] = "u%1",
        ["([^w][‿ ])w(" .. C .. ")"] = "%1u%2"
    },
    ["j"] = {["^([smT]ˤ?)ː"] = "%1", ["([‿ ]ə?)([smT]ˤ?)ː"] = "%1%2"},
    ["k"] = {["(" .. C .. "[ˤʷ]?)ː "] = "%1(ː) ", ["(" .. C .. "[ˤʷ]?)ː$"] = "%1(ː)"},
    ["l"] = {
        ["([ħʕχqʁ]ː?)æ"] = "%1ɑ",
        ["([ħʕχqʁ]ː?)i"] = "%1ɪ̙",
        ["([ħʕχqʁ]ː?)u"] = "%1ʊ̙",
        ["æ([ħʕχqʁ])"] = "ɑ%1",
        ["i([ħʕχqʁ])"] = "ɪ̙%1",
        ["u([ħʕχqʁ])"] = "ʊ̙%1",
        ["æ([^‿ ]-ˤ)"] = "ɑ%1",
        ["i([^‿ ]-ˤ)"] = "ɪ̙%1",
        ["u([^‿ ]-ˤ)"] = "ʊ̙%1",
        ["(ˤ[^‿ ]-)æ"] = "%1ɑ",
        ["(ˤ[^‿ ]-)i"] = "%1ɪ̙",
        ["(ˤ[^‿ ]-)u"] = "%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"] = {
        ["^(" .. V .. "?" .. C .. "[ˤʷ]?ː?" .. C .. "?[ˤʷ]?)([θT]ˤ?)$"] = "%1ə%2",
        ["^(" .. V .. "?" .. C .. "[ˤʷ]?ː?" .. C .. "?[ˤʷ]?)([θT]ˤ?[‿ ])"] = "%1ə%2",
        ["([‿ ]" .. V .. "?" .. C .. "[ˤʷ]?ː?" .. C .. "?[ˤʷ]?)([θT]ˤ?)$"] = "%1ə%2",
        ["([‿ ]" .. V .. "?" .. C .. "[ˤʷ]?ː?" .. C .. "?[ˤʷ]?)([θT]ˤ?[‿ ])"] = "%1ə%2",
        ["(" .. C .. "[ˤʷ]?ː?)(" .. C .. "[ˤʷ]?ː?[θT]ˤ?[‿ ])"] = "%1ə%2",
        ["(" .. C .. "[ˤʷ]?ː?)(" .. C .. "[ˤʷ]?ː?[θT]ˤ?)$"] = "%1ə%2",
        ["(" .. C .. "[ˤʷ]?ː?)([ɡɟʝDdðfɣʁkcçlmNnrsʃCwjzbβhxχʒJqħʕ][ˤʷ]?ː?[‿ ])"] = "%1ə%2",
        ["(" .. C .. "[ˤʷ]?ː?)([ɡɟʝDdðfɣʁkcçlmNnrsʃCwjzbβhxχʒJqħʕ][ˤʷ]?ː?)$"] = "%1ə%2",
        ["^(" .. C .. "?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?)(" .. C .. "[ˤʷ]?ː?)$"] = "%1ə%2",
        ["^(" .. C .. "?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?)(" .. C .. "[ˤʷ]?ː?[‿ ])"] = "%1ə%2",
        ["([‿ ]" .. C .. "?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?)(" .. C .. "[ˤʷ]?ː?)$"] = "%1ə%2",
        ["([‿ ]" .. C .. "?[ˤʷ]?ː?" .. C .. "?[ˤʷ]?)(" .. C .. "[ˤʷ]?ː?[‿ ])"] = "%1ə%2"
    },
    ["ø"] = {
        ["^(" .. C .. "[ˤʷ]?ː?)ə(" .. C .. "[ˤʷ]?[‿ ])"] = "%1%2",
        ["^ə(" .. C .. "[ˤʷ]?ː?[‿ ])"] = "%1",
        ["(" .. V .. "[‿ ]" .. C .. "[ˤʷ]?ː?)ə(" .. C .. "[ˤʷ]?[‿ ])"] = "%1%2",
        ["(" .. V .. "[‿ ])ə(" .. C .. "[ˤʷ]?ː?[‿ ])"] = "%1%2",
        ["(" .. V .. C .. "[ˤʷ]?ː?[‿ ])ə(" .. C .. "[ˤʷ]?[‿ ])"] = "%1%2",
        ["(" .. V .. "[‿ ])ə(" .. C .. "[ˤʷ]?ː?)$"] = "%1%2",
        ["(" .. V .. "[‿ ]" .. C .. "[ˤʷ]?ː?)ə(" .. C .. "[ˤʷ]?)$"] = "%1%2",
        ["(" .. V .. C .. "[ˤʷ]?ː?[‿ ])ə(" .. C .. "[ˤʷ]?)$"] = "%1%2"
    },
    ["O"] = {
        ["(" .. V .. C .. "[ˤʷ]?ː?)(" .. C .. "[ˤʷ]?" .. C .. "[ˤʷ]?)"] = "%1ə%2",
        ["(" .. V .. C .. "[ˤʷ]?ː?)(" .. C .. "[ˤʷ]?ː)"] = "%1ə%2",
        ["^(" .. C .. "[ˤʷ]?ː?)(" .. C .. "[ˤʷ]?" .. C .. "[ˤʷ]?)"] = "%1ə%2",
        ["^(" .. C .. "[ˤʷ]?ː?)(" .. C .. "[ˤʷ]?ː)"] = "%1ə%2",
        ["([‿ ]" .. C .. "[ˤʷ]?ː?)(" .. C .. "[ˤʷ]?" .. C .. "[ˤʷ]?)"] = "%1ə%2",
        ["([‿ ]" .. C .. "[ˤʷ]?ː?)(" .. C .. "[ˤʷ]?ː)"] = "%1ə%2",
        ["(" .. V .. "[‿ ]?" .. C .. "[ˤʷ]?ː?[‿ ])(" .. C .. "[ˤʷ]?" .. C .. "[ˤʷ]?)"] = "%1ə%2",
        ["(" .. V .. "[‿ ]?" .. C .. "[ˤʷ]?ː?[‿ ])(" .. C .. "[ˤʷ]?ː)"] = "%1ə%2",
        ["(" .. V .. "[‿ ]?" .. C .. "[ˤʷ]?" .. C .. "[ˤʷ]?[‿ ])(" .. C .. "[ˤʷ]?)"] = "%1ə%2",
    },
    ["p"] = {["əm"] = "m̩", ["əN"] = "n̪̩", ["əl"] = "l̩", ["ər"] = "r̩"},
    ["q"] = {
        ["əj"] = "ij",
        ["əʝ"] = "iʝ",
        ["əw"] = "uw"
    },
    ["Q"] = {
        ["ij([^)])"] = "i(j)%1",
        ["iʝ([^)])"] = "i(ʝ)%1",
        ["uw([^)])"] = "u(w)%1",
        ["ij$"] = "i(j)",
        ["iʝ$"] = "i(ʝ)",
        ["uw$"] = "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"] = {["([ ‿]j" .. C .. "?[ˤʷ]?" .. C .. "[ˤʷ]?" .. C .. "[ˤʷ]?)a a"] = "%1‿a", ["^(j" .. C .. "?[ˤʷ]?" .. C .. "[ˤʷ]?" .. C .. "[ˤʷ]?)a a"] = "%1‿a"},--include every verbal prefix to recognize only the a-final conjugated forms
    ["t"] = {["([æiu]) ([æiu])"] = "%1‿j%2"},
    ["T"] = {["([æiu]‿j)i"] = "%1"},
    ["u"] = {["kkʷ"] = "kʷkʷ", ["ɡɡʷ"] = "ɡʷɡʷ"}
}


local dialects = {}
dialects["Ayt Ndhir"] = {
    {{"u", "h", "r", "s", "i", "d", "f", "g"}, {true, "b"}},
    {{"o", "ø"}, {true, "O"}, {"q", "Q", "t", "T", "n", "e", "c", "j", "a"}, {true, "l"}, {"m", "k", "p"}}
}

function export.pronunciation_phonemic(word)
    m_scripts_util.checkScript(word, "Tfng")

    translit = (lang:transliterate(word))

    return mw.ustring.gsub(translit, '.', c)
end

function export.pronunciation_phonetic(word, dialect)
    local word = export.pronunciation_phonemic(word)
    local o = dialects[dialect]

    for j = 1, #o[1] do -- set of rules
        if o[1][j][1] == true then
            local N = ""
            while N ~= word do
                N = word
                for k = 2, #o[1][j] do -- rule
                    for x, y in pairs(r[o[1][j][k]]) do
                        word = s(word, x, y)
                    end
                end
            end
        else
            for k = 1, #o[1][j] do -- rule
                for x, y in pairs(r[o[1][j][k]]) do
                    word = s(word, x, y)
                end
            end
        end
    end

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

    for j = 1, #o[2] do -- set of o
        if o[2][j][1] == true then
            local N = ""
            while N ~= word do
                N = word
                for k = 2, #o[2][j] do -- rule
                    for x, y in pairs(r[o[2][j][k]]) do
                        word = s(word, x, y)
                    end
                end
            end
        else
            for k = 1, #o[2][j] do -- rule
                for x, y in pairs(r[o[2][j][k]]) do
                    word = s(word, x, y)
                end
            end
        end
    end

    word = s(word, "T", "t̪")
    word = s(word, "D", "d̪")
    word = s(word, "N", "n̪")
    word = s(word, "C", "t͡ʃ")
    word = s(word, "J", "d͡ʒ")

    return word
end

function export.show(frame)
    local args = frame:getParent().args
    local page_title = mw.title.getCurrentTitle().text

    local p, results, results_ayt_ndhir = {}, {}, {}

    if args[1] then
        for index, item in ipairs(args) do
            table.insert(p, (item ~= "") and item or nil)
        end
    else
        p = {page_title}
    end
 
    if args["r"] then
        for _, word in ipairs(p) do
            table.insert(results, {pron = "/" .. export.pronunciation_phonemic(word) .. "/"})
            table.insert(results_ayt_ndhir, {pron = "[" .. args["r"] .. "]"})
        end
    else
        for _, word in ipairs(p) do
            table.insert(results, {pron = "/" .. export.pronunciation_phonemic(word) .. "/"})
            table.insert(results_ayt_ndhir, {pron = "[" .. export.pronunciation_phonetic(word, "Ayt Ndhir") .. "]"})
        end
    end

    return "* " .. m_IPA.format_IPA_full(lang, results) .. "\n** " .. m_a.show({"Ayt Ndhir"}) .. " " .. m_IPA.format_IPA_full(lang, results_ayt_ndhir)
end

return export