Module:qlu-pron: Difference between revisions
Removal of dialects Tag: Reverted |
Tag: Undo |
||
| Line 113: | Line 113: | ||
{"ʦ", "t͡s"}, {"ʣ", "d͡z"}, | {"ʦ", "t͡s"}, {"ʣ", "d͡z"}, | ||
{"([ntdszl])", "%1" .. laminal}, {"(͡[sz])" .. laminal, "%1" .. dental}, | {"([ntdszl])", "%1" .. laminal}, {"(͡[sz])" .. laminal, "%1" .. dental}, | ||
} | |||
local upper_rules = { | |||
{"a", "ɐ"}, {"ɸ", "f"}, {"β", "v"}, {"θ", "t"}, {"ð", "d"}, | |||
{"^[ˌˈ]+", ""}, {"[ˌˈ]+", "·"}, {"··", "·"}, {"ju", "y"}, {"ew", "y"}, {"[ɛI]", "ɐj"}, {"ɔ", "aw"}, | |||
{"r", "ɾ"}, {"r·r", "ʀ"}, {"d·([ʣʤ])", "·%1"}, {"t·([ʦʧ])", "·%1"}, | |||
{"ʣ", "z"}, {"ʦ", "s"}, {"ʧ", "ʃ"}, {"ʤ", "ʒ"}, | |||
{"(" .. consonants .. ")·%1", "·%1"}, | |||
{"(" .. vowels .. ")·s(" .. vowels .. ")", "%1·z%2"}, | |||
{"ḱ", "k"}, {"ǵ", "g"}, {"ʎ", "ʎ" .. raised}, | |||
{"k([ieɛj])", "c%1"}, {"g([ieɛj])", "ɟ%1"}, | |||
{"ã", "ɐᵑ"}, {"ẽ", "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 192: | Line 239: | ||
function export.crux(term, no_stress, outputs) | function export.crux(term, no_stress, outputs) | ||
local ret = {} | local ret, dialects = {}, {} | ||
term = mw.ustring.lower(term) | term = mw.ustring.lower(term) | ||
| Line 211: | Line 258: | ||
for _, rule in ipairs(phonetic_rules) do | for _, rule in ipairs(phonetic_rules) do | ||
phonetic = gsub(phonetic, rule[1], rule[2]) | phonetic = gsub(phonetic, rule[1], rule[2]) | ||
end | |||
local upper, bolognese, paulistan = phonemic, phonetic, phonemic | |||
for _, rule in ipairs(upper_rules) do | |||
upper = gsub(upper, rule[1], rule[2]) | |||
end | |||
for _, rule in ipairs(bolognese_rules) do | |||
bolognese = gsub(bolognese, rule[1], rule[2]) | |||
end | |||
for _, rule in ipairs(paulistan_rules) do | |||
paulistan = gsub(paulistan, rule[1], rule[2]) | |||
end | end | ||
| Line 220: | Line 280: | ||
phonemic = gsub(phonemic, rule[1], rule[2]) | phonemic = gsub(phonemic, rule[1], rule[2]) | ||
phonetic = gsub(phonetic, rule[1], rule[2]) | phonetic = gsub(phonetic, rule[1], rule[2]) | ||
upper = gsub(upper, rule[1], rule[2]) | |||
bolognese = gsub(bolognese, rule[1], rule[2]) | |||
paulistan = gsub(paulistan, rule[1], rule[2]) | |||
end | end | ||
| Line 232: | Line 295: | ||
end | end | ||
end | end | ||
dialects["paulistan"] = paulistan | |||
dialects["bolognese"] = bolognese | |||
dialects["upper"] = upper | |||
return {phonemic, phonetic} | return {phonemic, phonetic}, dialects | ||
end | end | ||
function merge_tables(foo, bar) | |||
local merged_table = {} | |||
for key, value1 in pairs(foo) do | |||
local value2 = bar[key] | |||
if value2 then | |||
merged_table[key] = value1 .. " ".. value2 | |||
else | |||
merged_table[key] = value1 | |||
end | |||
end | |||
for key, value2 in pairs(bar) do | |||
if not merged_table[key] then | |||
merged_table[key] = value2 | |||
end | |||
end | |||
return merged_table | |||
end | |||
function separate_word(term, no_stress) | function separate_word(term, no_stress) | ||
local phonemic, phonetic = {}, {} | local phonemic, phonetic, dialects = {}, {}, {} | ||
local m, t = "", "" | local m, t, d = "", "", {} | ||
if match(term, " ") then | if match(term, " ") then | ||
for word in gsplit(term, " ") do | for word in gsplit(term, " ") do | ||
local ret = export.crux(word, no_stress) | local ret, d = export.crux(word, no_stress) | ||
m = ret[1]; t = ret[2] | m = ret[1]; t = ret[2] | ||
if #phonemic == 0 or #phonetic == 0 then | if #phonemic == 0 or #phonetic == 0 then | ||
phonemic, phonetic = {m}, {t} | phonemic, phonetic, dialects = {m}, {t}, d | ||
else | else | ||
table.insert(phonemic, m) | table.insert(phonemic, m) | ||
table.insert(phonetic, t) | table.insert(phonetic, t) | ||
d = merge_tables(dialects, d) | |||
end | end | ||
end | end | ||
| Line 256: | Line 346: | ||
end | end | ||
return {table.concat(phonemic, " "), table.concat(phonetic, " ")} | return {table.concat(phonemic, " "), table.concat(phonetic, " ")}, dialects | ||
end | end | ||
| Line 270: | Line 360: | ||
local args = require("Module:parameters").process(parent_args, params) | local args = require("Module:parameters").process(parent_args, params) | ||
local term = args[1]; local no_stress = args.rs | local term = args[1]; local no_stress = args.rs | ||
local ret = separate_word(term, no_stress) | 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 | |||
if value ~= phonemic and value ~= phonetic then | |||
table.insert(IPA_args, {pron = '[' .. value .. ']', a = {sub(key,1,1)}, separator = "\n** "}) | |||
end | |||
end | |||
return "* " .. m_IPA.format_IPA_full({ lang = lang, items = IPA_args }) | return "* " .. m_IPA.format_IPA_full({ lang = lang, items = IPA_args }) | ||