Module:qlu-pron: Difference between revisions
No edit summary |
No edit summary |
||
| (52 intermediate revisions by the same user not shown) | |||
| Line 27: | Line 27: | ||
local function dediacv(str, diacritic) | local function dediacv(str, diacritic) | ||
return gsub(mw.ustring.toNFD(str), diacritic, "") | return gsub(mw.ustring.toNFD(str), diacritic, "") | ||
end | end | ||
| Line 63: | Line 52: | ||
{"qu?", "ḱ"}, {"þ", "θ"}, {"v", "β"}, | {"qu?", "ḱ"}, {"þ", "θ"}, {"v", "β"}, | ||
{"%-", ""}, | --{"%-", ""}, | ||
} | } | ||
| Line 89: | Line 78: | ||
local phonetic_rules = { | local phonetic_rules = { | ||
-- Gorgia Toscana | -- Gorgia Toscana | ||
{"(" .. vowels .. "·)p(" .. vowels .. ")", "%1ɸ%2"}, | {"(" .. vowels .. "·)p(" .. vowels .. ")", "%1ɸ%2"}, {"p$", "ɸ"}, | ||
{"(" .. vowels .. "·)b(" .. vowels .. ")", "%1β%2"}, | {"(" .. vowels .. "·)b(" .. vowels .. ")", "%1β%2"}, {"b$", "β"}, | ||
{"(" .. vowels .. "·)t(" .. vowels .. ")", "%1θ%2"}, | {"(" .. vowels .. "·)t(" .. vowels .. ")", "%1θ%2"}, {"t$", "θ"}, | ||
{"(" .. vowels .. "·)d(" .. vowels .. ")", "%1ð%2"}, | {"(" .. vowels .. "·)d(" .. vowels .. ")", "%1ð%2"}, {"d$", "ð"}, | ||
{"(" .. vowels .. "·)k(" .. vowels .. ")", "%1x%2"}, | {"(" .. vowels .. "·)k(" .. vowels .. ")", "%1x%2"}, {"k$", "x"}, | ||
{"(" .. vowels .. "·)g(" .. vowels .. ")", "%1ɣ%2"}, | {"(" .. vowels .. "·)g(" .. vowels .. ")", "%1ɣ%2"}, {"g$", "ɣ"}, | ||
{"I", "i"}, | {"I", "i"}, | ||
{"^ɸ", "f"}, {"(" .. consonants .. ")([·ˈˌ]?)ɸ", "%1%2f"}, | {"^ɸ", "f"}, {"(" .. consonants .. ")([·ˈˌ]?)ɸ", "%1%2f"}, | ||
{"^β", "v"}, {"(" .. consonants .. ")([·ˈˌ]?)β", "%1%2v"}, | {"^β", "v"}, {"(" .. consonants .. ")([·ˈˌ]?)β", "%1%2v"}, | ||
{"ḱ", "kʷ"}, {"ǵ", " | {"ḱ", "kʷ"}, {"ǵ", "gʷ"}, | ||
{"k([ieɛj])", "k" .. advanced .. "%1"}, {"g([ieɛj])", "g˖%1"}, | {"k([ieɛj])", "k" .. advanced .. "%1"}, {"g([ieɛj])", "g˖%1"}, | ||
{"k([oɔu])", "q%1"}, {"g([oɔu])", "ɢ%1"}, | {"k([oɔu])", "q%1"}, {"g([oɔu])", "ɢ%1"}, | ||
| Line 107: | Line 96: | ||
-- vowels | -- vowels | ||
{"iw", "ɪw"}, | |||
{"iw", "ɪw | |||
{"ɐw", "ɒw"}, {"aw", "ɑw"}, | {"ɐw", "ɒw"}, {"aw", "ɑw"}, | ||
{"ij", "ɪj"}, {" | {"ij", "ɪj"}, | ||
{"ej", "e" .. advanced .. "j"}, {"oj", "o" .. advanced .. "j"}, | |||
{"ɛj", "ɛ" .. raised .. "j"}, {"ɔ" .. advanced .. "j", "ɐ" .. raised .. "j"}, | -- consonants | ||
{"ʈ", "t"}, | |||
{"[ʤʧʃ]", "%1ʷ"}, | |||
} | |||
local narrow_phonetic_rules = { | |||
{"ɔ", "ɔ" .. advanced}, {"uw", "u" .. lowered .. "w"}, {"ew", "e" .. c.diaer .. lowered .. "w"}, {"ow", "o" .. lowered .. "w"}, | |||
{"ɛw", "æ" .. c.diaer .. "w"}, {"ɔ" .. advanced .. "w", "ʌw"}, {"ej", "e" .. advanced .. "j"}, {"oj", "o" .. advanced .. "j"}, | |||
{"uj", "u" .. lowered .. "j"}, {"ɛj", "ɛ" .. raised .. "j"}, {"ɔ" .. advanced .. "j", "ɐ" .. raised .. "j"}, | |||
{"ɐj", "ɔ" .. raised .. "j"}, {"aj", "a" .. c.diaer .. raised .. "j"}, | {"ɐj", "ɔ" .. raised .. "j"}, {"aj", "a" .. c.diaer .. raised .. "j"}, | ||
{"ʦ", "t͡s"}, {"ʣ", "d͡z"}, | |||
{"([ntdszl])", "%1" .. laminal}, {"(͡[sz])" .. laminal, "%1" .. dental}, | {"([ntdszl])", "%1" .. laminal}, {"(͡[sz])" .. laminal, "%1" .. dental}, | ||
} | } | ||
local upper_rules = { | local upper_rules = { | ||
{"a", "ɐ"}, {"ɸ", "f"}, {"β", "v"}, {"θ", "t"}, {"ð", "d"}, | {"a", "ɐ"}, {"ɸ", "f"}, {"β", "v"}, {"θ", "t"}, {"ð", "d"}, | ||
{"^[ˌˈ]", ""}, {"[ˌˈ]", "·"}, {"ju", "y"}, {"[ɛI]", "ɐj"}, {"ɔ", "aw"}, | {"^[ˌˈ]+", ""}, {"[ˌˈ]+", "·"}, {"··", "·"}, {"ju", "y"}, {"ew", "y"}, {"[ɛI]", "ɐj"}, {"ɔ", "aw"}, | ||
{"r", "ɾ"}, {"r·r", "ʀ"}, {"d·([ʣʤ])", "·%1"}, {"t·([ʦʧ])", "·%1"}, | {"r", "ɾ"}, {"r·r", "ʀ"}, {"d·([ʣʤ])", "·%1"}, {"t·([ʦʧ])", "·%1"}, | ||
{"ʣ", "z"}, {"ʦ", "s"}, {"ʧ", "ʃ"}, {"ʤ", "ʒ"}, | {"ʣ", "z"}, {"ʦ", "s"}, {"ʧ", "ʃ"}, {"ʤ", "ʒ"}, | ||
| Line 133: | Line 125: | ||
{"k([ieɛj])", "c%1"}, {"g([ieɛj])", "ɟ%1"}, | {"k([ieɛj])", "c%1"}, {"g([ieɛj])", "ɟ%1"}, | ||
{"ã", "ɐᵑ"}, {"ẽ", "eᵑ"}, {"ĩ", "iᵑ"}, {"õ", "oᵑ"}, {"ũ", "uᵑ"}, | {"ã", "ɐᵑ"}, {"ẽ", "eᵑ"}, {"ĩ", "iᵑ"}, {"õ", "oᵑ"}, {"ũ", "uᵑ"}, | ||
-- final devoicing | |||
{"b$", "p"}, {"d$", "t"}, {"g$", "k"}, {"β$", "ɸ"}, {"z$", "s"}, | |||
} | |||
local bolognese_rules = { | |||
{"ʧ", "ʦ"}, {"ʤ", "ʣ"}, | |||
-- apophony | |||
{"e([^·ˈˌ]*[·ˈˌ][^·ˈˌ]*[ijuw]+[^·ˈˌ]*[·ˈˌ])", "i%1"}, {"e([^·ˈˌ]*[·ˈˌ][^·ˈˌ]*[ijuw]+[^·ˈˌ]*)$", "i%1"}, | |||
{"ɛ([^·ˈˌ]*[·ˈˌ][^·ˈˌ]*[ijuw]+[^·ˈˌ]*[·ˈˌ])", "e%1"}, {"ɛ([^·ˈˌ]*[·ˈˌ][^·ˈˌ]*[ijuw]+[^·ˈˌ]*)$", "e%1"}, | |||
{"o([^·ˈˌ]*[·ˈˌ][^·ˈˌ]*[ijuw]+[^·ˈˌ]*[·ˈˌ])", "u%1"}, {"o([^·ˈˌ]*[·ˈˌ][^·ˈˌ]*[ijuw]+[^·ˈˌ]*)$", "u%1"}, | |||
{"ɔ([^·ˈˌ]*[·ˈˌ][^·ˈˌ]*[ijuw]+[^·ˈˌ]*[·ˈˌ])", "o%1"}, {"ɔ([^·ˈˌ]*[·ˈˌ][^·ˈˌ]*[ijuw]+[^·ˈˌ]*)$", "o%1"}, | |||
{"([ntdsθzðʦʣlrmŋɲɴ][·ˈˌ]?)[fɸ]", "%1p͡f"}, {"([ntdsθzðʦʣlrmŋɲɴ][·ˈˌ]?)s", "%1ʦ"}, {"([ntdsθzðʦʣlrmŋɲɴ][·ˈˌ]?)θ", "%1t͡θ"}, | |||
{"ɣ", "ɣ˕"}, {"ð", "ð" .. lowered}, {"v", "ʋ"}, | |||
{"(·[^·]*)ɛ", "%1e"}, {"(·[^·]*)ɔ", "%1o"}, {"^([^·]*)ɛ", "%1e"}, {"^([^·]*)ɔ", "%1o"}, | |||
{"(·[^·]*)([eo])", "%1%2" .. lowered}, {"^([^·]*)([eo])", "%1%2" .. lowered}, | |||
} | |||
local paulistan_rules = { | |||
{"^([ˈˌ]?)s(" .. consonants .. ")", "es%1%2"}, {"r", "ɾ"}, {"d·([ʣʤ])", "·%1"}, {"t·([ʦʧ])", "·%1"}, {"[ʧʦ]", "s"}, {"ʤ", "ʒ"}, | |||
{"(" .. consonants .. ")([ˈ·ˌ])%1", "%2%1"}, {"ð", "d"}, {"d([iĩjɪ])", "ʤ%1"}, {"t([iĩjɪ])", "ʧ%1"}, | |||
{"^([ˈˌ]?)ɾ", "%1ʁ"}, {"ɾ([ˈˌ·]?)(" .. consonants .. ")", "ɹ%1%2"}, {"([pbtdkg])$", "%1ĭ"}, | |||
{"([mnŋɲ])(" .. vowels .. ")([ˈˌ·]?)([mnŋɲ])", "%1%2" .. c.tilde .. "%3%4"}, | |||
{"ḱ", "kw"}, {"ǵ", "gw"}, {"(" .. vowels .. ")([ˈˌ·]?)ɲ", "%1" .. c.tilde .. "%2j̃"}, | |||
{"(·[^·ˈˌ]*)j", "%1ɪ̯"}, {"^(·[^·ˈˌ]*)j", "%1ɪ̯"}, | |||
{"(·[^·ˈˌ]*)w", "%1ʊ̯"}, {"^(·[^·ˈˌ]*)w", "%1ʊ̯"}, | |||
{"(·[^·ˈˌ]*)i", "%1ɪ"}, {"^(·[^·ˈˌ]*)i", "%1ɪ"}, | |||
{"(·[^·ˈˌ]*)u", "%1ʊ"}, {"^(·[^·ˈˌ]*)u", "%1ʊ"}, | |||
{"(·[^·ˈˌ]*)e", "%1i"}, {"^(·[^·ˈˌ]*)e", "%1i"}, | |||
{"(" .. vowels .. ")([ˈˌ·]?)ŋ", "%1" .. c.tilde .. "%2w" .. c.tilde}, | |||
{"ẽ", "ẽj" .. c.tilde}, {"õ", "õw" .. c.tilde}, {c.tilde .. c.tilde, c.tilde}, | |||
} | } | ||
| Line 138: | Line 165: | ||
-- Escaped characters | -- Escaped characters | ||
{"ʤ", "d͡ʒ"}, {"ʧ", "t͡ʃ"}, {"ʈ", "t"}, {"ʦ", "t͡s"}, {"ʣ", "d͡z"}, | {"ʤ", "d͡ʒ"}, {"ʧ", "t͡ʃ"}, {"ʈ", "t"}, {"ʦ", "t͡s"}, {"ʣ", "d͡z"}, | ||
{"g", " | {"g", "g"}, {"ḱ", "kʷ"}, {"ǵ", "gʷ"}, {"I", "i"}, | ||
{"·", "."}, | {"·?ˈ·?", "ˈ"}, {"·", "."}, | ||
} | } | ||
local function syllabify(word) | local function syllabify(word, no_stress) | ||
local clusters = m_table.listToSet({ | local clusters = m_table.listToSet({ | ||
"s[ptʈkfɸ]", "z[bdgβʤmnlr]", | "s[ptʈkfɸ]", "z[bdgβʤmnlr]", | ||
| Line 162: | Line 189: | ||
word = gsub(word, "··", "·"); word = gsub(word, "·$", ""); word = gsub(word, "^·", "") | word = gsub(word, "··", "·"); word = gsub(word, "·$", ""); word = gsub(word, "^·", "") | ||
word = gsub(word, "(" .. consonants .. ")·(" .. vowels .. ")", "·%1%2") | word = gsub(word, "(" .. consonants .. ")·(" .. vowels .. ")", "·%1%2") | ||
word = gsub(word, "·?(" .. consonants .. ")% | word = gsub(word, "(·?)(" .. consonants .. ")%2(" .. vowels .. "*)", "%2%1%2%3") | ||
word = gsub(word, "·(" .. consonants .. ")$", "%1"); word = gsub(word, "^(" .. consonants .. ")·", "%1") | word = gsub(word, "·(" .. consonants .. ")$", "%1"); word = gsub(word, "^(" .. consonants .. ")·", "%1") | ||
word = gsub(word, "·(.)·", "%1·") | word = gsub(word, "·(.)·", "%1·") | ||
word = gsub(word, "·s(" .. voiceless .. ")", "s·%1") | |||
word = gsub(word, "(" .. consonants .. ")s·(" .. voiceless .. ")", "%1·s%2") | |||
word = gsub(word, "ï(" .. vowels .. ")", "i·%1") | word = gsub(word, "ï(" .. vowels .. ")", "i·%1"); word = gsub(word, "ḱ·ḱ", "k·ḱ") | ||
word = gsub(word, "·?d([ʤʣ])", "d·%1"); word = gsub(word, "·tʦ", "t·ʦ") | word = gsub(word, "·?d([ʤʣ])", "d·%1"); word = gsub(word, "·tʦ", "t·ʦ") | ||
word = gsub(word, "·?ŋg", "ŋ·g"); word = gsub(word, "··", "·") | word = gsub(word, "·?ŋg", "ŋ·g"); word = gsub(word, "··", "·") | ||
for cluster, _ in pairs(clusters) do | |||
word = gsub(word, "(" .. consonants .. "+)·(" .. consonants .. "+)", function(c1,c2) return match(c1 .. c2, cluster) and "·" .. c1 .. c2 or c1 .. "·" .. c2 end) | |||
end | |||
word = gsub(word, "%-", "·"); word = gsub(word, "··", "·") | |||
end | end | ||
local syllables = split(word, "·"); | local syllables = split(word, "·"); | ||
if #syllables == 1 then return | if no_stress or (#syllables == 1 and not match(word, "[" .. c.acute .. c.circ .. "]")) then | ||
return dediacv(word, "[" .. c.acute .. c.circ .. "]") | |||
end | |||
local first_stress = "[âêîôû]" | local first_stress = "[âêîôû]" | ||
| Line 203: | Line 238: | ||
end | end | ||
function export.crux(term, outputs) | function export.crux(term, no_stress, outputs) | ||
local ret, dialects = {}, {} | local ret, dialects = {}, {} | ||
term = mw.ustring.lower(term) | term = mw.ustring.lower(term) | ||
| Line 211: | Line 246: | ||
end | end | ||
term = syllabify(term) | term = syllabify(term, no_stress) | ||
term = term:gsub("·([ˈˌ])", "%1") | term = term:gsub("·?([ˈˌ])·?", "%1") | ||
term = term:gsub("ˌˌ", "ˌ") | term = term:gsub("ˌˌ", "ˌ") | ||
| Line 219: | Line 254: | ||
phonemic = gsub(phonemic, rule[1], rule[2]) | phonemic = gsub(phonemic, rule[1], rule[2]) | ||
end | end | ||
local phonetic = phonemic | local phonetic = phonemic | ||
| Line 226: | Line 260: | ||
end | end | ||
local upper, bolognese, paulistan = phonemic, | local upper, bolognese, paulistan = phonemic, phonetic, phonemic | ||
for _, rule in ipairs(upper_rules) do | for _, rule in ipairs(upper_rules) do | ||
upper = gsub(upper, rule[1], rule[2]) | upper = gsub(upper, rule[1], rule[2]) | ||
end | end | ||
for _, rule in ipairs(bolognese_rules) do | |||
bolognese = gsub(bolognese, rule[1], rule[2]) | bolognese = gsub(bolognese, rule[1], rule[2]) | ||
end | end | ||
| Line 237: | Line 271: | ||
for _, rule in ipairs(paulistan_rules) do | for _, rule in ipairs(paulistan_rules) do | ||
paulistan = gsub(paulistan, rule[1], rule[2]) | paulistan = gsub(paulistan, rule[1], rule[2]) | ||
end]] | end | ||
for _, rule in ipairs(narrow_phonetic_rules) do | |||
phonetic = gsub(phonetic, rule[1], rule[2]) | |||
end | |||
for _, rule in ipairs(last_rules) do | for _, rule in ipairs(last_rules) do | ||
| Line 258: | Line 296: | ||
end | end | ||
dialects["paulistan"] = paulistan | |||
dialects["bolognese"] = bolognese | |||
dialects["upper"] = upper | dialects["upper"] = upper | ||
return {phonemic, phonetic}, dialects | return {phonemic, phonetic}, dialects | ||
| Line 287: | Line 325: | ||
function separate_word(term) | function separate_word(term, no_stress) | ||
local phonemic, phonetic, dialects = {}, {}, {} | local phonemic, phonetic, dialects = {}, {}, {} | ||
local m, t, d = "", "", {} | local m, t, d = "", "", {} | ||
| Line 293: | Line 331: | ||
if match(term, " ") then | if match(term, " ") then | ||
for word in gsplit(term, " ") do | for word in gsplit(term, " ") do | ||
local ret, d = export.crux(word) | local ret, d = export.crux(word, no_stress) | ||
m = ret[1]; t = ret[2] | m = ret[1]; t = ret[2] | ||
| Line 305: | Line 343: | ||
end | end | ||
else | else | ||
return export.crux(term) | return export.crux(term, no_stress) | ||
end | end | ||
| Line 314: | Line 352: | ||
local parent_args = frame:getParent().args | local parent_args = frame:getParent().args | ||
local params = { | local params = { | ||
[1] = { default = mw.title.getCurrentTitle().nsText == 'Template' and " | [1] = { default = mw.title.getCurrentTitle().nsText == 'Template' and "agghiu" or mw.title.getCurrentTitle().text }, | ||
["rs"] = {type = 'boolean'}, | |||
} | } | ||
local args = require("Module:parameters").process(parent_args, params) | local args = require("Module:parameters").process(parent_args, params) | ||
local term = args[1] | local term = args[1]; local no_stress = args.rs | ||
local ret, dialects = separate_word(term) | local ret, dialects = separate_word(term, no_stress) | ||
local phonemic = ret[1]; local phonetic = ret[2] | local phonemic = ret[1]; local phonetic = ret[2] | ||
local IPA_args = {{pron = '/' .. (phonemic or "test") .. '/', a = "Standard Ravennese"}, {pron = '[' .. (phonetic or "test2") .. ']'}} | local IPA_args = {{pron = '/' .. (phonemic or "test") .. '/', a = {"Standard Ravennese"}}, {pron = '[' .. (phonetic or "test2") .. ']'}} | ||
for key, value in pairs(dialects) do | for key, value in pairs(dialects) do | ||
if value ~= phonemic then | if value ~= phonemic and value ~= phonetic then | ||
table.insert(IPA_args, {pron = '[' .. value .. ']', a = {sub(key,1,1)}, separator = "\n** "}) | table.insert(IPA_args, {pron = '[' .. value .. ']', a = {sub(key,1,1)}, separator = "\n** "}) | ||
end | end | ||