Module:xchc-pron: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 109: Line 109:


function export.crux(term)
function export.crux(term)
term = mw.ustring.lower(mw.ustring.toNFD(term))
for _, rule in ipairs(first_rules) do
for _, rule in ipairs(first_rules) do
term = gsub(term, rule[1], rule[2])
term = gsub(term, rule[1], rule[2])
Line 123: Line 121:


function export.harmony(term)
function export.harmony(term)
local ipa = export.crux(term)
local ret = {
local ret = {
["roundness"] = ipa:match("[yuøo]") and "r" or ipa:match("[ie]") and "u" or "ar",
--["roundness"] = ipa:match("[yuøo]") and "r" or ipa:match("[ie]") and "u" or "ar",
["backness"] = ipa:match("ɜ") and "f" or ipa:match("ɔ") and "b" or "ab",
--["backness"] = ipa:match("ɜ") and "f" or ipa:match("ɔ") and "b" or "ab",
["roundness"] = term:match("[үуӯюөоё]") and "r" or term:match("[ыиӣэе]") and "u" or "ar",
["backness"] = term:match("э") and "f" or term:match("о̆") and "b" or "ab",
}
}
return ret
return ret
Line 135: Line 134:
for word in gsplit(term, " ") do
for word in gsplit(term, " ") do
local ipa = export.crux(term)
local ipa = export.crux(word)
if export.harmony(ipa).backness == "b" then ipa = ipa:gsub("a", "ɑ") end
if export.harmony(word).backness == "b" then ipa = ipa:gsub("a", "ɑ") end
if export.harmony(ipa).roundness == "r" then ipa = ipa:gsub("ɛ", "œ") end
if export.harmony(word).roundness == "r" then ipa = ipa:gsub("ɛ", "œ") end
if export.harmony(ipa).roundness == "u" then ipa = ipa:gsub("ɔ", "ʌ") end
if export.harmony(word).roundness == "u" then ipa = ipa:gsub("ɔ", "ʌ") end
table.insert(result, ipa)
table.insert(result, ipa)
Line 153: Line 152:
}
}
local args = require("Module:parameters").process(parent_args, params)
local args = require("Module:parameters").process(parent_args, params)
local term = args[1]
local term = mw.ustring.lower(mw.ustring.toNFD(args[1]))


local IPA_args = {}
local IPA_args = {}
local phonetic = separate_word(term)
local phonetic = separate_word(term)

Navigation menu