Module:mg-pron: Difference between revisions

no edit summary
No edit summary
No edit summary
 
(74 intermediate revisions by the same user not shown)
Line 8: Line 8:
local gsplit = mw.text.gsplit
local gsplit = mw.text.gsplit


local NASAL = u(0x0303) -- COMBINING TILDE, ̃
local N = u(0x0303) -- COMBINING TILDE, ̃
local NONSYLL = u(0x032F) -- COMBINING INVERTED BREVE BELOW, ̯
local NONSYLL = u(0x032F) -- COMBINING INVERTED BREVE BELOW, ̯
local ADV = u(0x031F) -- COMBINING PLUS SIGN BELOW, ̟
local ADV = u(0x031F) -- COMBINING PLUS SIGN BELOW, ̟
Line 16: Line 16:


local velar = "[kɡɣɫw]"; local palatal = "[ɲʧʃʎ]"
local velar = "[kɡɣɫw]"; local palatal = "[ɲʧʃʎ]"
local consonants = "[bkdhjlmnɲprɾstʃθβðɡɣzʧɫʎ]"
local consonants = "[bkdhjlmnɲprɾstʃθβðɡɣzʧɫʎɓ]"
local vowels = "[áéíóúaɑɐeɪɛiɔʊouwJ" .. ADV .. RET .. CEN .. "]"
local vowels = "[áéíóúaɑɐeɪɛiɔʊouwJąĄ" .. ADV .. RET .. CEN .. ACUTE .. "]"
local voiced = "[bdhʎjmnɲβðɡɣz]"
local voiced = "[bdhʎjmnɲβðɡɣzɓ]"


local function same(foo, bar)
local function same(foo, bar)
Line 26: Line 26:
end
end


local function remove_acute(str)
local function remove_acute(str, with_stress)
str = mw.ustring.toNFD(str)
str = mw.ustring.toNFD(str)
str = str:gsub(ACUTE, "")
str = gsub(str, ACUTE, "")
str = mw.ustring.toNFC(str)
str = mw.ustring.toNFC(str)
return str
return str == "Ą" and "ą" or (with_stress and "ˈ" or "") .. str
end
end


Line 39: Line 39:


local prelims = {
local prelims = {
{"r", "ɾ"}, {"ch", "ʧ"}, {"qu", "k"}, {"il", "ʎ"}, {"ñ", "ɲ"}, {"c", "k"},
{"r", "ɾ"}, {"ch", "ʧ"}, {"qu", "k"}, {"il", "ʎ"}, {"ñ", "ɲ"}, {"c", "k"}, --{"an$", "ɐn"},
{"[bv]", "β"}, {"gu?", "ɣ"}, {"d", "ð"},
{"[bv]", "β"}, {"gu?", "ɣ"}, {"d", "ð"}, {"ʎ$", "il"}, {"an$", "ą"}, {"án$", "Ą"},
{"z", "θ"}, {"x", "ʃ"}, {"(" .. vowels .. ")i(" .. vowels .. ")", "%1j%2"},
{"z", "θ"}, {"x", "ʃ"}, {"(" .. vowels .. ")i(" .. vowels .. ")", "%1j%2"}, {"ṡ", "z"},
{"(" .. vowels .. ")u", "%1w"}, {"u(" .. vowels .. ")", "w%1"}, {"(" .. vowels .. ")i", "%1J"}, {"i(" .. vowels .. ")", "J%1"},  
{"(" .. vowels .. ")u", "%1w"}, {"u(" .. vowels .. ")", "w%1"}, {"(" .. vowels .. ")i", "%1J"}, {"i(" .. vowels .. ")", "J%1"},  
}
}
Line 52: Line 52:
term = gsub(term, "·(" .. consonants .. ")·", "%1·")
term = gsub(term, "·(" .. consonants .. ")·", "%1·")
local syll = split(term, "·")
local syll = split(term, "·"); local noa = {}
local monosyll = {["n"] = "ˈ", ["pron"] = "", ["particle"] = "(ˈ)", ["prep"] = "(ˈ)", ["conj"] = "(ˈ)"}
local monosyll = {["n"] = "ˈ", ["pron"] = "", ["particle"] = "(ˈ)", ["prep"] = "(ˈ)", ["conj"] = "(ˈ)"}
Line 59: Line 59:
if not pos then error('Part of speech needed to determine stress') end
if not pos then error('Part of speech needed to determine stress') end
syll[1] = remove_acute(syll[1])
syll[1] = remove_acute(syll[1])
syll[1] = monosyll[pos] .. syll[1]
syll[1] = (monosyll[pos] or "(ˈ)") .. syll[1]
else
else
for _, s in ipairs(syll) do
if match(term, "[áéíóúĄ]") then
if match(s, "[áéíóú]") then
for _, s in ipairs(syll) do
s = "ˈ" .. remove_acute(s)
s = remove_acute(s, match(s, "[áéíóúĄ]") and true or false)
return table.concat(syll, "·")
table.insert(noa, s)
end
end
else
syll[#syll - 1] = "ˈ" .. syll[#syll - 1]
end
end
syll[#syll - 1] = "ˈ" .. syll[#syll - 1]
end
end


return table.concat(syll, "·")
return table.concat(#noa > 1 and noa or syll, "·")
end
end


local rules = {
local rules = {
{"([ɾs])·([ɾs])", function(s1, s2) return same(s1, s2) and "·ʰ" .. s1 or s1 .. s2 end}, -- rr and ss clusters, preaspirated
-- rr and ss clusters, preaspirated
{".$", {["a"] = "ɐ", ["e"] = "ɪ", ["o"] = "ʊ", ["n"] = NASAL}},
{"([ɾs])·(ˈ?)([ɾs])", function(s1, st, s2) return same(s1, s2) and "·" .. st .. "ʰ" .. s1 or s1 .. st .. s2 end},
{".$", {["a"] = "ɐ", ["e"] = "ɪ", ["o"] = "ʊ", ["n"] = N}},
{"l·", "ɫ·"}, {"l$", "ɫ"}, -- velarized [l]
{"l·", "ɫ·"}, {"l$", "ɫ"}, -- velarized [l]
{"a(" .. velar .. ")", "ɑ" .. ADV .. "%1"}, {"(" .. velar .. ")a", "%1ɑ" .. ADV}, -- [a] retracts next to velar consonants
{"a(" .. velar .. ")", "ɑ" .. ADV .. "%1"}, {"(" .. velar .. ")a", "%1ɑ" .. ADV}, -- [a] retracts next to velar consonants
{"a(" .. palatal .. ")", "a" .. RET .. "%1"}, {"(" .. palatal .. "a)", "%1" .. RET}, -- and advances next to palatal
{"a(" .. palatal .. ")", "a" .. RET .. "%1"}, {"(" .. palatal .. "a)", "%1" .. RET}, -- and advances next to palatal
{"s·(" .. voiced .. ")", "z·%1"}, {"(" .. vowels .. ")·s(" .. vowels .. ")", "%1·z%2"}, -- [s]-voicing
{"s·(" .. voiced .. ")", "z·%1"}, {"(" .. vowels .. ")·s(" .. vowels .. ")", "%1·z%2"}, {"%ss", "‿z"}, -- [s]-voicing
{"[Jj]m$", "y" .. NASAL}, {"m$", "u" .. NASAL}, {"n·", NASAL .. "·"}, -- [m] and [n] behave as nasalizers in codas and word-finally
{"[Jj]m$", "y" .. N}, {"m$", "u" .. N}, {"n·", N .. "·"}, -- [m] and [n] behave as nasalizers in codas and word-finally
{"e(" .. consonants .. ")·(" .. consonants .. ")", "ɛ%1·%2"}, {"o(" .. consonants .. ")·(" .. consonants .. ")", "ɔ%1·%2"},  
{"e(" .. N .. "?)·(" .. consonants .. ")", "ɛ%1·%2"}, {"o(" .. N .. "?)·(" .. consonants .. ")", "ɔ%1·%2"},
{"e(" .. consonants .. ")?·(" .. consonants .. "[aɐɑ])", "ɛ%1·%2"}, {"o(" .. consonants .. ")?·(" .. consonants .. "[aɐɑ])", "ɔ%1·%2"},
{"e(" .. consonants .. ")·(" .. consonants .. ")", "ɛ%1·%2"}, {"o(" .. consonants .. ")·(" .. consonants .. ")", "ɔ%1·%2"},
{"e(" .. N .. "?)?·(" .. consonants .. "[aɐɑąĄ])", "ɛ%1·%2"}, {"o(" .. N .. "?)?·(" .. consonants .. "[aɐɑąĄ])", "ɔ%1·%2"},
{"e(" .. N .. "?"  .. consonants .. ")?·(" .. consonants .. "[aɐɑąĄ])", "ɛ%1·%2"}, {"o(" .. N .. "?"  .. consonants .. ")?·(" .. consonants .. "[aɐɑąĄ])", "ɔ%1·%2"},
{"(" .. vowels .. "i)", "%1" .. NONSYLL}, {"w", "u" .. NONSYLL}, {"J", "i" .. NONSYLL},  
{"(" .. vowels .. "i)", "%1" .. NONSYLL}, {"w", "u" .. NONSYLL}, {"J", "i" .. NONSYLL},  
Line 90: Line 94:
{"(" .. consonants .. ")(·ˈ?)([βðɣ])", function(foo, bar, baz) return foo .. bar .. desoften[baz] end},
{"(" .. consonants .. ")(·ˈ?)([βðɣ])", function(foo, bar, baz) return foo .. bar .. desoften[baz] end},
{"ʧ", "(t)ʃ"}, {"a([^" .. RET .. "])", "a" .. CEN .. "%1"}, {"a" .. CEN .. NASAL, "a" .. RET .. NASAL}, {"·ˈ", "ˈ"}, {"·", "."},  
{"ʧ", "(t)ʃ"}, {"·ˈ", "ˈ"}, {"·", "."},
--{"a([^" .. RET .. "])", "a" .. CEN .. "%1"},
--{"([ɑa][" .. CEN .. RET .. ADV .. "])(ː?)" .. N, "%1" .. N .. "%2"}, {"a" .. CEN .. N, "a" .. RET .. N},
{"i" .. NONSYLL, "j"}, {"u" .. NONSYLL, "w"},  
}
}


Line 109: Line 118:
term = gsub(term, "([ɡɣ])", g and "%1" or "h")
term = gsub(term, "([ɡɣ])", g and "%1" or "h")
term = gsub(term, "hɑ" .. ADV, "ha" .. CEN)
term = gsub(term, "hɑ" .. ADV, "ha" .. CEN)
term = gsub(term, "(ˈ..?a" .. CEN .. ")", "%")  
term = gsub(term, "a" .. CEN .. "(" .. velar .. ")", "ɑ" .. ADV .. "%1")
term = gsub(term, "(ˈ.?.?[aɑ])([" .. ADV .. RET .. CEN .. "]?)([^.]*)", "%1%2ː%3")
term = gsub(term, "ːⁿ", "ⁿː")
term = gsub(term, "a([^" .. CEN .. ADV .. RET .. "])", "a" .. CEN .. "%1")
term = gsub(term, "ą", "a" .. CEN .. N); term = gsub(term, "Ą", "a" .. CEN .. N .. "ː")
term = gsub(term, "ɓ", "β") -- soft mutation
return term
return term
Line 160: Line 174:
if is_g then
if is_g then
ipa = ipa .. "\n* " .. line_format(separate_word(term, pos, true), {'g–h distinction'})
ipa = ipa .. "\n* " .. line_format(separate_word(term, pos, true), {'without [[w:gheada|gheada]]'})
end
end