Module:xchc-pron: Difference between revisions
No edit summary |
|||
| (6 intermediate revisions by the same user not shown) | |||
| Line 7: | Line 7: | ||
local split = mw.text.split | local split = mw.text.split | ||
local gsplit = mw.text.gsplit | local gsplit = mw.text.gsplit | ||
local lang = require("Module:languages").getByCode("xchc") | local lang = require("Module:languages").getByCode("xchc") | ||
| Line 16: | Line 12: | ||
local m_IPA = require("Module:IPA") | local m_IPA = require("Module:IPA") | ||
local M = c.macron | |||
local B = c.breve | |||
local D = c.diaer | |||
local nb_cons = "mnŋɲptbdkɡfvszʃʒxɣhʧʦʤʣlrɾʎ" | local nb_cons = "mnŋɲptbdkɡfvszʃʒxɣhʧʦʤʣlrɾʎ" | ||
local consonants = "[" .. nb_cons .. "]" | local consonants = "[" .. nb_cons .. "]" | ||
local consonantsAsIs = "[мньӈбдгвзжғлрйпткфсшӀчц]" | |||
local vowels = "[ыиэеаяүөуюоёӯӣɜɔ]" | |||
local export = {} | local export = {} | ||
local first_rules = { | local first_rules = { | ||
| Line 78: | Line 63: | ||
{"l[ьі]", "ʎ"}, {"n[ьі]", "ɲ"}, {"[ьі]", "j"}, | {"l[ьі]", "ʎ"}, {"n[ьі]", "ɲ"}, {"[ьі]", "j"}, | ||
{"(" .. consonants .. ") | {"(" .. consonants .. ")%1", "%1ː"}, | ||
{"r$", "ɾ"}, {"([ŋkɡxɣh])a", "%1ɑ"}, {"a(ː?[ŋkɡxɣh])", "ɑ%1"} | {"r$", "ɾ"}, {"([ŋkɡxɣh])a", "%1ɑ"}, {"a(ː?[ŋkɡxɣh])", "ɑ%1"} | ||
} | } | ||
| Line 111: | Line 96: | ||
-- Remove diacritics for module calculations based on vowels | -- Remove diacritics for module calculations based on vowels | ||
function export.simplify(term) | function export.simplify(term) | ||
term = mw. | term = mw.ustring.toNFD(term):gsub(c.macron, "") -- vowel length | ||
term = term:gsub("э" .. c.breve, "ɛ"); term = term:gsub("о" .. c.breve, "ɔ") | term = term:gsub("э" .. c.breve, "ɛ"); term = term:gsub("о" .. c.breve, "ɔ") | ||
term = mw.ustring.toNFC(term):gsub("ё", "о"); term = term:gsub("е" .. c.diaer, "о") | term = mw.ustring.toNFC(term):gsub("ё", "о"); term = term:gsub("е" .. c.diaer, "о") | ||
| Line 132: | Line 117: | ||
function export.harmony(term) | function export.harmony(term) | ||
term = export.simplify(term) | term = export.simplify(term) | ||
local termR, termB = term, term | |||
local unrounded = "[ыиӣеэ]"; local rounded = "[үөуӯюоё]"; local neutralR = "[ɛɔая]" | |||
local front = "ɛ"; local back = "ɔ"; local neutralB = "[ыиӣеэүөуӯюоёая]" | |||
-- for words that violate vowel harmony (compounds and loanwords) | |||
local exception = (term:match(unrounded) and term:match(rounded)) or (term:match(front) and term:match(back)) | |||
if exception then | |||
termR = term:gsub(neutralR, ""); termB = term:gsub(neutralB, "") | |||
termR = termR:match("(".. vowels .. consonantsAsIs .. "*)$") or termR; termB = termB:match("(" .. vowels .. consonants .. "*)$") or termB | |||
end | |||
local ret = { | local ret = { | ||
["roundness"] = | ["roundness"] = termR:match(unrounded) and "u" or termR:match(rounded) and "r" or "ar", | ||
["backness"] = | ["backness"] = termB:match(front) and "f" or termB:match(back) and "b" or "ab", | ||
} | } | ||
return ret | return ret | ||