Module:qhv-pron: Difference between revisions
No edit summary |
No edit summary |
||
| (12 intermediate revisions by the same user not shown) | |||
| Line 10: | Line 10: | ||
local export = {} | local export = {} | ||
local velar = " | local palatal = "ɲʎɟj" | ||
local velar = "kgxɣ" | |||
local uvular = "q" | local uvular = "q" | ||
local consonants = "[ | local consonants = "[mpbvwθntdszlrɾɲŋɴʎhɥjɟṛʃ" .. velar .. uvular .. "]" | ||
local NONSYLLABIC = u(0x032F) -- non-syllabic, combining inverted breve below | local NONSYLLABIC = u(0x032F) -- non-syllabic, combining inverted breve below | ||
local DIPHTHONG = u(0x035C) -- double articulation, combining double breve below | local DIPHTHONG = u(0x035C) -- double articulation, combining double breve below | ||
local vowels = "[aeiouyáéíóúýàèìòùỳː" .. NONSYLLABIC .. DIPHTHONG .. "]" | local vowels = "[aeiouyáéíóúýàèìòùỳː" .. NONSYLLABIC .. DIPHTHONG .. "]" | ||
local vowelsonly = "[aeiouyáéíóúýàèìòùỳ" .. NONSYLLABIC .. DIPHTHONG .. "]" | |||
local rules = { | local rules = { | ||
{"rh", "ṛ"}, {"th", "θ"}, {"lj", "ʎ"}, {"ñ", "ɲ"}, {"kh", "x"}, {"[ | {"rh", "ṛ"}, {"mh", "m"}, {"th", "θ"}, {"lj", "ʎ"}, {"ñ", "ɲ"}, {"kh", "x"}, {"[gg]h", "ɣ"}, {"g", "g"}, {"j", "ɟ"}, {"sh", "ʃ"}, | ||
{"([aāáà][eo])", "%1" .. NONSYLLABIC}, {"([iíuú])([aāeēoōáéóàèò])", "%1" .. DIPHTHONG .. "%2"}, | {"([aāáà][eo])", "%1" .. NONSYLLABIC}, {"([iíuú])([aāeēoōáéóàèò])", "%1" .. DIPHTHONG .. "%2"}, | ||
| Line 24: | Line 26: | ||
{"à", "áː"}, {"è", "éː"}, {"ì", "íː"}, {"ò", "óː"}, {"ù", "úː"}, {"ỳ", "ýː"}, | {"à", "áː"}, {"è", "éː"}, {"ì", "íː"}, {"ò", "óː"}, {"ù", "úː"}, {"ỳ", "ýː"}, | ||
{"n([" .. | {"n([" .. palatal .. "])", "ɲ%1"}, {"n([" .. velar .. "])", "ŋ%1"}, {"n([" .. uvular .. "])", "ɴ%1"}, | ||
{"ɲi", "ni"}, {"ʎi", "li"}, | |||
} | } | ||
| Line 31: | Line 34: | ||
} | } | ||
function export.write_stress(term, from_module) | |||
local pattern = "(" .. consonants .. "*".. vowels .. "*" .. consonants .. "-)" | local pattern = "(" .. consonants .. "*".. vowels .. "*" .. consonants .. "-)" | ||
local weight = {} | local weight = {} | ||
term = gsub(term, pattern, "·%1") | term = gsub(term, pattern, "·%1") | ||
term = gsub(term, "^·", "") | term = gsub(term, "^·", "") | ||
term = gsub(term, "·$", "") | |||
term = gsub(term, "·(" .. consonants .. ")·", "·%1") | term = gsub(term, "·(" .. consonants .. ")·", "·%1") | ||
term = gsub(term, "·(" .. consonants .. ")$", "%1") | term = gsub(term, "·(" .. consonants .. ")$", "%1") | ||
term = gsub(term, "·(" .. consonants .. ")(" .. consonants .. ")", "%1·%2") | term = gsub(term, "·(" .. consonants .. ")(" .. consonants .. ")", "%1·%2") | ||
term = gsub(term, "([ | term = gsub(term, "([ptkbdg])·([rlṛsz])", "·%1%2") | ||
term = gsub(term, "·$", "") | term = gsub(term, "·(" .. consonants .. "?" .. consonants .. ")$", "%1") | ||
local syllables = split(term, "·") | local syllables = split(term, "·") | ||
if from_module then return #syllables end -- allow other modules to know the number of syllables | |||
if #syllables == 1 then return table.concat(syllables) end -- account for monosyllables | if #syllables == 1 then return table.concat(syllables) end -- account for monosyllables | ||
for i, syllable in ipairs(syllables) do | for i, syllable in ipairs(syllables) do | ||
| Line 72: | Line 79: | ||
end | end | ||
return write_stress(term) | return export.write_stress(term, false) | ||
end | end | ||
function export. | function export.postclassical_crux(term) | ||
local | local postclassicalrules = { | ||
{" | {"sri(".. vowelsonly .. ")", "ɟ%1"}, {"sˈri(".. vowelsonly .. ")", "ˈɟ%1"}, {"sr", "ɟ"}, {"sˈr", "ˈɟ"}, | ||
} | } | ||
term = export.crux(term) | term = export.crux(term) | ||
for _, | for _, postclassicalrule in ipairs(postclassicalrules) do | ||
term = gsub(term, | term = gsub(term, postclassicalrule[1], postclassicalrule[2]) | ||
end | end | ||
| Line 93: | Line 99: | ||
local bits = {} | local bits = {} | ||
for _, item in ipairs(items) do | for _, item in ipairs(items) do | ||
local bit = | local bit = item.pron | ||
table.insert(bits, bit) | table.insert(bits, bit) | ||
end | end | ||
| Line 100: | Line 106: | ||
local function format_IPA(items) | local function format_IPA(items) | ||
return "[[ | return "[[wikt:Wiktionary:International Phonetic Alphabet|IPA]]<sup>([[IPA for High Valyrian|key]])</sup>: " .. IPA_span(items) | ||
end | |||
local function format_IPA_bare(items) | |||
return IPA_span(items) | |||
end | end | ||
function line_format(pronunciation, register) | function line_format(pronunciation, register) | ||
local full_pronunciations = {} | local full_pronunciations = {} | ||
local IPA_args = {{pron = ' | local IPA_args = {{pron = '/' .. pronunciation .. '/'}} | ||
table.insert(full_pronunciations, format_IPA(IPA_args)) | table.insert(full_pronunciations, format_IPA(IPA_args)) | ||
return "(''" .. table.concat(register, ", ") .. "'')" .. ' ' .. table.concat(full_pronunciations, ' or ') | return "(''" .. table.concat(register, ", ") .. "'')" .. ' ' .. table.concat(full_pronunciations, ' or ') | ||
end | |||
function line_format_bare(pronunciation) | |||
local full_pronunciations = {} | |||
local IPA_args = {{pron = '/' .. pronunciation .. '/'}} | |||
table.insert(full_pronunciations, format_IPA_bare(IPA_args)) | |||
return table.concat(full_pronunciations, ' or ') | |||
end | end | ||
| Line 114: | Line 131: | ||
for word in gsplit(term, " ") do | for word in gsplit(term, " ") do | ||
if b then table.insert(result, export. | if b then table.insert(result, export.postclassical_crux(word)) | ||
else table.insert(result, export.crux(word)) end | else table.insert(result, export.crux(word)) end | ||
end | end | ||
| Line 123: | Line 140: | ||
function export.show(frame) | function export.show(frame) | ||
local params = { | local params = { | ||
[1] = { default = mw.title.getCurrentTitle(). | [1] = { template_default = "kostōba", default = mw.title.getCurrentTitle().text }, | ||
nocat = { type = "boolean"}, | |||
} | } | ||
local args = require("Module:parameters").process(frame:getParent().args, params) | local args = require("Module:parameters").process(frame:getParent().args, params) | ||
local term = args[1] | local term = args[1] | ||
local ipa = " | local ipa = "" | ||
ipa = ipa .. line_format(separate_word(term, false), {' | ipa = ipa .. line_format(separate_word(term, false), {'Classical'}) | ||
if export.crux(term) ~= export. | if export.crux(term) ~= export.postclassical_crux(term) then | ||
ipa = ipa .. " | ipa = ipa .. "<br/>" .. line_format(separate_word(term, true), {'Post-Classical'}) | ||
end | end | ||
ipa = gsub(ipa, "ṛ", "r̥") | ipa = gsub(ipa, "ṛ", "r̥") | ||
ipa = gsub(ipa, "([ | ipa = gsub(ipa, u(0x032F), "") | ||
ipa = gsub(ipa, u(0x035C), "") | |||
ipa = gsub(ipa, "([áéíóúý])", function(v) return deacuter[v] end) | |||
return ipa | return ipa | ||