Module:ha-IPA/sandbox
Appearance
- This module sandbox lacks a documentation subpage. Please create it.
- Useful links: root page • root page’s subpages • links • transclusions • testcases • sandbox of (diff)
local export = {}
local m_IPA = require("Module:IPA")
local m_a = require("Module:accent qualifier")
local lang = require("Module:languages").getByCode("ha")
local s = mw.ustring.gsub
local C = "[ɡɟkTcʃSfDJjɽrʔmɓbfnɗdtzslwhpŋɲ]"
local V = "[áéíóúɛ́ɔ́àèìòùɛ̀ɔ̀âêîôûɛ̂ɔ̂]"
local i = {
[1] = {"E", "ɛ́"},
[2] = {"Ḕ", "ɛ̀ː"},
[3] = {"Ē", "ɛ́ː"},
[4] = {"È", "ɛ̀"},
[5] = {"Ê", "E"},
[6] = {"O", "ɔ́"},
[7] = {"Ṑ", "ɔ̀ː"},
[8] = {"Ō", "ɔ́ː"},
[9] = {"Ò", "ɔ̀"},
[10] = {"Ô", "O"},
[11] = {"R", "r̃"}
}
local c = {
[1] = {"ʼ", "'"},
[2] = {"([gkƙ])%1([wy])", "%1%2%1%2"},
[3] = {"tts(h?)", "ts%1ts%1"},
[4] = {"ssh", "shsh"},
[5] = {"ffy", "fyfy"},
[6] = {"cch'", "ch'ch'"},
[7] = {"''y", "'y'y"},
[8] = {"gw", "ɡʷ"},
[9] = {"gy", "ɟ"},
[10] = {"kw", "kʷ"},
[11] = {"ch'", "Tʼ"},
[12] = {"c", "T"},
[13] = {"ky", "c"},
[14] = {"ƙw", "kʷʼ"},
[15] = {"ƙy", "cʼ"},
[16] = {"tsh", "Tʼ"},
[17] = {"sh", "ʃ"},
[18] = {"ts", "Sʼ"},
[19] = {"fy", "fʲ"},
[20] = {"j", "D"},
[21] = {"'y", "J"},
[22] = {"y", "j"},
[23] = {"ƴ", "J"},
[24] = {"g", "ɡ"},
[25] = {"ƙ", "kʼ"},
[26] = {"r̃", "R"},
[27] = {"r", "ɽ"},
[28] = {"R", "r"},
[29] = {"'", "ʔ"},
[30] = {"a", "á"},
[31] = {"ā̀", "àː"},
[32] = {"ā", "áː"},
[33] = {"e", "é"},
[34] = {"ḕ", "èː"},
[35] = {"ē", "éː"},
[36] = {"i", "í"},
[37] = {"ī̀", "ìː"},
[38] = {"ī", "íː"},
[39] = {"o", "ó"},
[40] = {"ṑ", "òː"},
[41] = {"ō", "óː"},
[42] = {"u", "ú"},
[43] = {"ū̀", "ùː"},
[44] = {"ū", "úː"},
[45] = {"([âêîôûEO])", "%1ː"},
[46] = {"^(" .. V .. ")", "ʔ%1"},
[47] = {"(.[ -/])(" .. V .. ")", "%1ʔ%2"},
[48] = {"(.)[-/](.)", "%1%2"},
[49] = {"(" .. V .. "ː?" .. C .. "?[ʷʲ]?ʼ?)(" .. C .. "[ʷʲ]?ʼ?)%f" .. V, "%1.%2"},
[50] = {"([áàâ]ː?)[íìî]", "%1i"},
[51] = {"([áàâ]ː?)[úùû]", "%1u"},
[52] = {"âː([iu])", "â%1"},
[53] = {"([âêîôûɛ̂ɔ̂])ː(" .. C .. "[ʷʲ]?ʼ?.)", "%1%2"},
[54] = {"([âêîôûɛ̂ɔ̂])ː(" .. C .. "[ʷʲ]?ʼ?)$", "%1%2"},
[55] = {"T", "t͡ʃ"},
[56] = {"S", "(t)s"},
[57] = {"D", "(d)ʒ"},
[58] = {"J", "j̰"},
[59] = {"E", "ɛ̂"},
[60] = {"O", "ɔ̂"}
}
local idk = {
[1] = {"ɛ́", "é"},
[2] = {"ɛ̀", "è"},
[3] = {"ɛ̂", "ê"},
[4] = {"ɔ́", "ó"},
[5] = {"ɔ̀", "ò"},
[6] = {"ɔ̂", "ô"}
}
local SKH = {
[1] = {"%(d%)ʒ", "d͡ʒ"},
[2] = {"f", "ɸ"},
[3] = {"k(ʼ?[ɛ́ɛ̀ɛ̂éèêíìî])", "c%1"},
[4] = {"ɡ([ɛ́ɛ̀ɛ̂éèêíìî])", "ɟ%1"},
[5] = {"([kɡ])(ʼ?[ɔ́ɔ̀ɔ̂óòôúùû])", "%1ʷ%2"},
[6] = {"d͡ʒ%.d͡ʒ", "d.d͡ʒ"},
[7] = {"t͡ʃ%.t͡ʃ", "t.t͡ʃ"},
[8] = {"[kɡ]%.([cɟkɡ]ʷ?ʼ?)", "%1.%1"},
[9] = {"%(t%)sʼ", "sʼ"},
[10] = {"n([ -%.]?[bɓmpɸw])", "m%1"},
[11] = {"n([ -%.]?[jcɟ])", "ɲ%1"},
[12] = {"n([ -%.]?)([lrɽ])", "%2%1%2"},
[13] = {"n([ -%.]?[ kɡhʔ])", "ŋ%1"},
[14] = {"n$", "ŋ"},
[15] = {"á([jɲ])", "ɛ́%1"},
[16] = {"à([jɲ])", "ɛ̀%1"},
[17] = {"â([jɲ])", "ɛ̂%1"},
[18] = {"([jj̰ɟc]ʼ?)á([^ː])", "%1ɛ́%2"},
[19] = {"([jj̰ɟc]ʼ?)à([^ː])", "%1ɛ̀%2"},
[20] = {"([jj̰ɟc]ʼ?)â([^ː])", "%1ɛ̂%2"},
[21] = {"([jj̰ɟc]ʼ?)á$", "%1ɛ́"},
[22] = {"([jj̰ɟc]ʼ?)à$", "%1ɛ̀"},
[23] = {"([jj̰ɟc]ʼ?)â$", "%1ɛ̂"},
[24] = {"([^hʔ])á([ -%.])", "%1ə́%2"},
[25] = {"([^hʔ])à([ -%.])", "%1ə̀%2"},
[26] = {"([^hʔ])â([ -%.])", "%1ə̂%2"},
[27] = {"([^hʔ])á$", "%1ə́"},
[28] = {"([^hʔ])à$", "%1ə̀"},
[29] = {"([^hʔ])â$", "%1ə̂"},
[30] = {"hó(" .. C .. "[ʷʲ]?ʼ?[ -%.])", "hɔ́%1"},
[31] = {"hò(" .. C .. "[ʷʲ]?ʼ?[ -%.])", "hɔ̀%1"},
[32] = {"hô(" .. C .. "[ʷʲ]?ʼ?[ -%.])", "hɔ̂%1"},
[33] = {"hó(" .. C .. "[ʷʲ]?ʼ?)$", "hɔ́%1"},
[34] = {"hò(" .. C .. "[ʷʲ]?ʼ?)$", "hɔ̀%1"},
[35] = {"hô(" .. C .. "[ʷʲ]?ʼ?)$", "hɔ̂%1"},
[36] = {"[éó](" .. C .. "[ʷʲ]?ʼ?[ -%.])", "á%1"},
[37] = {"[èò](" .. C .. "[ʷʲ]?ʼ?[ -%.])", "à%1"},
[38] = {"[êô](" .. C .. "[ʷʲ]?ʼ?[ -%.])", "â%1"},
[39] = {"[éó](" .. C .. "[ʷʲ]?ʼ?)$", "á%1"},
[40] = {"[èò](" .. C .. "[ʷʲ]?ʼ?)$", "à%1"},
[41] = {"[êô](" .. C .. "[ʷʲ]?ʼ?)$", "â%1"},
[42] = {"í([^ː])", "ɪ́%1"},
[43] = {"ì([^ː])", "ɪ̀%1"},
[44] = {"î([^ː])", "ɪ̂%1"},
[45] = {"í$", "ɪ́"},
[46] = {"ì$", "ɪ̀"},
[47] = {"î$", "ɪ̂"},
[48] = {"jú([^ː])", "jí%1"},
[49] = {"jù([^ː])", "jì%1"},
[50] = {"jû([^ː])", "jî%1"},
[51] = {"jú$", "jí"},
[52] = {"jù$", "jì"},
[53] = {"jû$", "jî"},
[54] = {"([ʃʒɽrnɗdtzsl]ʼ?)ú([^ː])", "%1ɪ́%2"},
[55] = {"([ʃʒɽrnɗdtzsl]ʼ?)ù([^ː])", "%1ɪ̀%2"},
[56] = {"([ʃʒɽrnɗdtzsl]ʼ?)û([^ː])", "%1ɪ̂%2"},
[57] = {"([ʃʒɽrnɗdtzsl]ʼ?)ú$", "%1ɪ́"},
[58] = {"([ʃʒɽrnɗdtzsl]ʼ?)ù$", "%1ɪ̀"},
[59] = {"([ʃʒɽrnɗdtzsl]ʼ?)û$", "%1ɪ̂"},
[60] = {"ú([^ː])", "ʊ́%1"},
[61] = {"ù([^ː])", "ʊ̀%1"},
[62] = {"û([^ː])", "ʊ̂%1"},
[63] = {"ú$", "ʊ́"},
[64] = {"ù$", "ʊ̀"},
[65] = {"û$", "ʊ̂"},
[66] = {"([^hʔ])ái", "%1éi"},
[67] = {"([^hʔ])ài", "%1èi"},
[68] = {"(%.[^hʔ])âi", "%1êi"},
[69] = {"([^hʔ])âi%.", "%1êi."}
} --Standard/Kano also has final /m/ as [ŋ], but not in ideophones, so an override is needed. In recent loanwords they (/o/ et /e/) can be preserved as [ɔ] or [ɛ] (respectively) in closed syllables; we probably want an override for this.
function export.pronunciation_phonemic(word)
for a = 1, #i do
word = s(word, i[a][1], i[a][2])
end
word = mw.ustring.lower(word)
for a = 1, #c do
word = s(word, c[a][1], c[a][2])
end
return word
end
function export.idk(word)
for a = 1, #idk do
word = s(word, idk[a][1], idk[a][2])
end
return word
end
function export.pronunciation_phonetic(word, dialect, ideo)
if dialect == "SKH" then
if ideo ~= "1" then
word = s(word, "m$", "ŋ")
end
for a = 1, #SKH do
word = s(word, SKH[a][1], SKH[a][2])
end
end
return word
end
function export.show(frame)
local args = frame:getParent().args
local p, results, results_ha = {}, {}, {}
if not args[1] or (args[1] == "") then
error("Please put the word as the first positional parameter!")
else
for index, item in ipairs(args) do
table.insert(p, (item ~= "") and item or nil)
end
end
for _, word in ipairs(p) do
word = export.pronunciation_phonemic(word)
table.insert(results, {pron = "/" .. export.idk(word) .. "/"})
table.insert(results_ha, {pron = "[" .. export.pronunciation_phonetic(word, "SKH", args["ideo"]) .. "]"})
end
if args["niger"] == "1" then
return m_IPA.format_IPA_full { lang = lang, items = results }
else
return m_IPA.format_IPA_full { lang = lang, items = results } .. "\n** " .. m_a.format_qualifiers(lang, {"Standard Kano Hausa"}) .. " " .. m_IPA.format_IPA_full { lang = lang, items = results_ha }
end
end
return export