Module:pine-pron: Difference between revisions

no edit summary
No edit summary
No edit summary
 
(23 intermediate revisions by the same user not shown)
Line 20: Line 20:
["y"] = "ʏ", ["i"] = "ɪ", ["e"] = "ɛ",
["y"] = "ʏ", ["i"] = "ɪ", ["e"] = "ɛ",
["u"] = "ʊ", ["o"] = "ɔ", ["a"] = "ɑ",
["u"] = "ʊ", ["o"] = "ɔ", ["a"] = "ɑ",
["ů"] = "œ"
}
}


local long_vowels = {
local long_vowels = {
["a"] = "æː", ["e"] = "eː", ["i"] = "iː",
["o"] = "oː", ["u"] = "uː", ["y"] = "yː",
["ả"] = "æː", ["ẻ"] = "eː", ["ỉ"] = "iː",
["ả"] = "æː", ["ẻ"] = "eː", ["ỉ"] = "iː",
["ỏ"] = "oː", ["ủ"] = "uː", ["ỷ"] = "yː",
["ỏ"] = "oː", ["ủ"] = "uː", ["ỷ"] = "yː",
Line 46: Line 45:
end
end
end
end


local export = {}
local export = {}


local word_internal_clusters = require("Module:table").listToSet({
function export.vowel_harmony(term)
"m·pp", "m·p", "m·b", "n·tt", "n·t", "n·d", "n·dv",
local polarity = {
"n·ts", "n·tsv", "n·tsġ", "n·tsġv", "n·ttṡ", "n·tṡ",
["au"] = "back", ["[ei]?u[oa]?"] = "back", ["o[ai]?"] = "back", ["[ủỏ]"] = "back",
"n·tṡv", "n·ƛƛ", "n·ƛ", "n·ƛv", "n·kk", "n·kkv", "n·k", "n·kv",
["a[iy]"] = "front", ["ey"] = "front", ["ů[aei]?"] = "front", ["[ei]ů"] = "front", ["[ủỷả]"] = "front"
"p·ṃ",  
}
})
 
for pat, harmony in pairs(polarity) do
--[[m ṃ p b v
if find(term, pat) then return harmony end
t d ḍ s ṡ ts tṡ r ṛ l ḷ ƛ lį ḷį n ṇ nį ṇį dn ng kn
end
k g ġ h hį ḥ kṇ tġ]]
return "neutral"
end


function export.syllabify_from_spelling(term)
-- exportable to be used by [[Module:pine-noun]]
function export.syllabify_from_spelling(term, is_ipa)
local vowels = "[" .. vowels_spelling .. "]"
local vowels = "[" .. vowels_spelling .. "]"
local consonants = consonants_spelling --lazy_consonants
local consonants = consonants_spelling --lazy_consonants
term = term:gsub("(t[sṡ])", {["ts"] = "ʦ", ["tṡ"] = "ʧ"})
term = gsub(term, "(t[sṡ])", {["ts"] = "ʦ", ["tṡ"] = "ʧ"})
local words = split(term, "%s")
local words = split(term, "%s")
for i, word in ipairs(words) do
for i, word in ipairs(words) do
word = word:gsub("(" .. consonants .. "*" .. vowels .. "+)(" .. consonants .. "*)", "%1.%2")
word = gsub(word, "(" .. consonants .. "*)(" .. vowels .. "+)(" .. consonants .. "*)", "%1%2·%3")
word = word:gsub("%.(" .. consonants .. "?)$", "%1")
word = gsub(word, "·(" .. consonants .. "?)$", "%1")
word = word:gsub("%.(" .. consonants .. ")(" .. consonants .. "+)", "%1.%2")
word = gsub(word, "·(" .. consonants .. ")(" .. consonants .. "+)", "%1·%2")
word = gsub(word, "(" .. consonants .. ")·%1", "·%1%1")
word = gsub(word, "(" .. vowels .. ")(" .. consonants .. ")·v(" .. vowels .. ")", "%1·%2v%3")
word = gsub(word, "(" .. vowels .. ")t·([ʦʧ])(" .. vowels .. ")", "%1·t%2%3")
words[i] = word
words[i] = word
end
end
term = table.concat(words, " ")
if not is_ipa then
term = gsub(term, "([ʦʧ])", {["ʦ"] = "ts", ["ʧ"] = "tṡ"})
end
--[[ substitutions for easier processing
return term
local digraphs = {
["tṡ"] = "ʧ", ["ng"] = "ŋ", ["ts"] = "ʦ",
["gį"] = "ɟ", ["nį"] = "ɲ", ["ṇį"] = "ɳ",
["kį"] = "c", ["ḥį"] = "ʔ", ["ḍį"] = "θ",
["hį"] = "ɕ", ["lį"] = "ʎ", ["ḷį"] = "ʟ",
}
term = term:gsub("(.)%1į", "%1įː") -- e.g. nnį > nį:
for digraph, repl in pairs(digraphs) do
        term = term:gsub(digraph, repl)
    end
-- Split between spaces if term is multiword
local words = split(term, "%s")
for i, word in ipairs(words) do
word = word:gsub("(" .. consonants .. "ː?)(" .. consonants .. "+)", "%1·%2")
word = word:gsub("^(" .. consonants .. ")·", "%1"); word = word:gsub("·(" .. consonants .. ")$", "%1")
words[i] = word
end]]
return table.concat(words, " ")
end
end


function export.crux(term)
function export.crux(term)
term = export.syllabify_from_spelling(term)
term = export.syllabify_from_spelling(term, true)
local debug_syllables = true
if debug_syllables then
return term
end
-- default to short lax vowels
-- default to short lax vowels
term = term:gsub("[aeiouy]", laxen); term = term:gsub("ů", "œ")
term = gsub(term, "[aeiouyů]", laxen)
-- long vowels
-- long vowels
local nfd_term = mw.ustring.toNFD(term)
term = gsub(term, "([ảẻỉỏủỷ])", long_vowels)
nfd_term = nfd_term:gsub("([aeiouy])" .. c.hook, function(v)
term = gsub(term, "ɔɑ", "ɑː"); term = gsub(term, "ɛœ", "øː")
return long_vowels[v] or long_vowels[v .. c.hook]
end)
term = mw.ustring.toNFC(nfd_term)
term = term:gsub("ɔɑ", "ɑː"); term = term:gsub("ɛœ", "øː")
-- diphthongized vowels
-- diphthongized vowels
term = term:gsub("ʊɔ", "ʊu"); term = term:gsub("œɑ", "øy"); term = term:gsub("œɛ", "ʏy")
term = gsub(term, "ʊɔ", "ʊu"); term = gsub(term, "œɑ", "øy"); term = gsub(term, "œɛ", "ʏy")
-- labiodiphthongized vowels
-- labiodiphthongized vowels
term = term:gsub("vʏy", "ᶣy"); term = term:gsub("vøy", "ᶣø"); term = term:gsub("vʊu", "ʷu") -- different in eastern
term = gsub(term, "vʏy", "ᶣy"); term = gsub(term, "vøy", "ᶣø"); term = gsub(term, "vʊu", "ʷu") -- different in eastern
term = term:gsub("^ᶣ", "ɥ"); term = term:gsub("^ʷ", "w")
term = gsub(term, "^ᶣ", "ɥ"); term = gsub(term, "^ʷ", "w")
-- diphthongs
-- diphthongs
term = term:gsub("([ɛɑ])ʏ", "%1y"); term = term:gsub("ɑy", "æy")
term = gsub(term, "([ɛɑ])ʏ", "%1y"); term = gsub(term, "ɑy", "æy")
term = term:gsub("([ɛɑɪ]ʊ)", "%1u"); term = term:gsub("ɪœ", "ɪy")
term = gsub(term, "([ɛɑɪ]ʊ)", "%1u"); term = gsub(term, "ɪœ", "ɪy")
-- simple consonant subtitutions
-- simple consonant subtitutions
term = term:gsub("ṡ", "ʃ")
term = gsub(term, "ṡ", "ʃ")
term = term:gsub("ḷ", "ɬ"); term = term:gsub("ḥ", "ʔ");  
term = gsub(term, "ḷ", "ɬ"); term = gsub(term, "ḥ", "ʔ");  
-- geminate consonants
-- geminate consonants
term = term:gsub("(.)%1", "%1ː"); term = term:gsub("ng", "ŋː")
term = gsub(term, "(.)%1", "%1ː"); term = gsub(term, "ng", "ŋː")
-- final substitutions
local final_subs = {
local final_subs = {
["ʧ"] = "t͡ʃ",
["ʧ"] = "t͡ʃ",
Line 144: Line 120:
["ṇ"] = "n" .. c.ringbelow,
["ṇ"] = "n" .. c.ringbelow,
["ṛ"] = "r" .. c.ringbelow,
["ṛ"] = "r" .. c.ringbelow,
["·"] = ".",
}
}
term = term:gsub("[ʧʦgƛṃṇṛ]", final_subs)
term = gsub(term, "[ʧʦgƛṃṇṛ·]", final_subs)
return term
return term