Module:qlu-pron: Difference between revisions

no edit summary
No edit summary
No edit summary
 
(6 intermediate revisions by the same user not shown)
Line 78: 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ʷ"}, {"ǵ", ""},  
{"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 147: Line 147:


local paulistan_rules = {
local paulistan_rules = {
{"^([ˈˌ]?)s", "%1es"}, {"r", "ɾ"}, {"d·([ʣʤ])", "·%1"}, {"t·([ʦʧ])", "·%1"}, {"[ʧʦ]", "s"}, {"ʤ", "ʒ"},   
{"^([ˈˌ]?)s(" .. consonants .. ")", "es%1%2"}, {"r", "ɾ"}, {"d·([ʣʤ])", "·%1"}, {"t·([ʦʧ])", "·%1"}, {"[ʧʦ]", "s"}, {"ʤ", "ʒ"},   
{"(" .. consonants .. ")([ˈ·ˌ])%1", "%2%1"}, {"ð", "d"}, {"d([iĩjɪ])", "ʤ%1"}, {"t([iĩjɪ])", "ʧ%1"},
{"(" .. consonants .. ")([ˈ·ˌ])%1", "%2%1"}, {"ð", "d"}, {"d([iĩjɪ])", "ʤ%1"}, {"t([iĩjɪ])", "ʧ%1"},
{"^([ˈˌ]?)ɾ", "%1ʁ"}, {"ɾ([ˈˌ·]?)(" .. consonants .. ")", "ɹ%1%2"}, {"([pbtdkg])$", "%1ĭ"},
{"^([ˈˌ]?)ɾ", "%1ʁ"}, {"ɾ([ˈˌ·]?)(" .. consonants .. ")", "ɹ%1%2"}, {"([pbtdkg])$", "%1ĭ"},
Line 165: Line 165:
-- Escaped characters
-- Escaped characters
{"ʤ", "d͡ʒ"}, {"ʧ", "t͡ʃ"}, {"ʈ", "t"}, {"ʦ", "t͡s"}, {"ʣ", "d͡z"},
{"ʤ", "d͡ʒ"}, {"ʧ", "t͡ʃ"}, {"ʈ", "t"}, {"ʦ", "t͡s"}, {"ʣ", "d͡z"},
{"g", "ɡ"}, {"ḱ", "kʷ"}, {"ǵ", "ɡʷ"}, {"I", "i"},
{"g", "g"}, {"ḱ", "kʷ"}, {"ǵ", ""}, {"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 194: Line 194:
word = gsub(word, "·s(" .. voiceless .. ")", "s·%1")
word = gsub(word, "·s(" .. voiceless .. ")", "s·%1")
word = gsub(word, "(" .. consonants .. ")s·(" .. voiceless .. ")", "%1·s%2")
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, "··", "·")
Line 207: Line 207:
local syllables = split(word, "·");
local syllables = split(word, "·");
if #syllables == 1 then return dediacv(table.concat(syllables), "[" .. c.acute .. c.circ .. "]") end -- account for monosyllables
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 236: 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 244: 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 323: 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 329: 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 341: Line 343:
    end
    end
     else
     else
     return export.crux(term)
     return export.crux(term, no_stress)
     end
     end


Line 351: Line 353:
     local params = {
     local params = {
         [1] = { default = mw.title.getCurrentTitle().nsText == 'Template' and "agghiu" or mw.title.getCurrentTitle().text },
         [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]