48,357
edits
No edit summary |
No edit summary |
||
| Line 14: | Line 14: | ||
local vowels_spelling = "aeiouyůảẻỉỏủỷ" | local vowels_spelling = "aeiouyůảẻỉỏủỷ" | ||
local vowels = "[aɑæɔoʊuʏyɛœøiɪe]" | local vowels = "[aɑæɔoʊuʏyɛœøiɪe]" | ||
local lazy_consonants = "[^" .. vowels_spelling .."]" | local lazy_consonants = "[^" .. vowels_spelling .."ː]" | ||
local laxen = { | local laxen = { | ||
| Line 34: | Line 34: | ||
return retval, nsubs > 0 | return retval, nsubs > 0 | ||
end | end | ||
-- apply gsub() repeatedly until no change | |||
local function gsub_repeatedly(term, foo, bar) | |||
while true do | |||
local new_term = gsub(term, foo, bar) | |||
if new_term == term then | |||
return term | |||
end | |||
term = new_term | |||
end | |||
end | |||
local export = {} | local export = {} | ||
| Line 49: | Line 61: | ||
function export.syllabify_from_spelling(term) | function export.syllabify_from_spelling(term) | ||
local vowels = "[" .. vowels_spelling .. "]" | |||
local consonants = lazy_consonants | |||
-- substitutions for easier processing | |||
local digraphs = { | local digraphs = { | ||
["tṡ"] = "ʧ", ["ng"] = "ŋ", | ["tṡ"] = "ʧ", ["ng"] = "ŋ", ["ts"] = "ʦ", | ||
[" | ["gį"] = "ɟ", ["nį"] = "ɲ", ["ṇį"] = "ɳ", | ||
["kį"] = "c", ["ḥį"] = "ʔ", ["ḍį"] = "θ", | |||
["hį"] = "ɕ", ["lį"] = "ʎ", ["ḷį"] = "ʟ", | |||
} | } | ||
term = term:gsub("(.)%1į", "%1įː") -- e.g. nnį > nį: | |||
term = term:gsub("..", digraphs) | |||
return | -- Split between spaces if term is multiword | ||
local words = split(term, "%s") | |||
for _, word in ipairs(word) do | |||
word = word:gsub("(" .. consonants .. "ː?)(" .. consonants .. "+)", "%1·%2") | |||
word = word:gsub("^(" .. consonants .. ")·", "%1"); word = word:gsub("·(" .. consonants .. ")$", "%1") | |||
end | |||
return table.concat(words, " ") | |||
end | end | ||
function export.crux(term) | function export.crux(term) | ||
term = syllabify_from_spelling(term) | |||
-- default to short lax vowels | -- default to short lax vowels | ||
term = term:gsub("[aeiouy]", laxen); term = term:gsub("ů", "œ") | term = term:gsub("[aeiouy]", laxen); term = term:gsub("ů", "œ") | ||