Module:xchc-noun: Difference between revisions

No edit summary
No edit summary
Line 22: Line 22:
local vowel = "[aeɛioɔuyø]"
local vowel = "[aeɛioɔuyø]"


local function matche(foo, pat)
local function wordpron(w)
local ipa = m_ipa.crux(foo)
return m_ipa.crux(w)
return ipa:match(pat .. "ː?$")
end
end


local function gsubh(word, o, e, r, u, def)
local function gsubh(word, o, e, r, u, def)
local ipa = m_ipa.crux(word)
local ipa = wordpron(word)
local backh = ipa:match("ɛ") and "ɛ" or ipa:match("ɔ") and "ɔ" or nil
local backh = ipa:match("ɛ") and "ɛ" or ipa:match("ɔ") and "ɔ" or nil
local roundh = ipa:match("[yuɔo]") and "r" or ipa:match("[ie]") and "u" or nil
local roundh = ipa:match("[yuɔo]") and "r" or ipa:match("[ie]") and "u" or nil
Line 38: Line 37:
local parent_args = frame:getParent().args
local parent_args = frame:getParent().args
local numbers = {}
local decl = {}
local g = NAMESPACE == "Template" and "a" or parent_args[1]
local g = NAMESPACE == "Template" and "a" or parent_args[1]
local word = NAMESPACE == "Template" and "өра̄" or parent_args["word"] or PAGENAME
local word = NAMESPACE == "Template" and "өра̄" or parent_args["word"] or PAGENAME
Line 46: Line 43:
if g ~= "i" and g ~= "a" then error("Unknown gender: it must be either ‘i’ or ‘a’") end
if g ~= "i" and g ~= "a" then error("Unknown gender: it must be either ‘i’ or ‘a’") end
local function wordpron(w)
return m_ipa.crux(w)
end
local data = {}
local data = {}
Line 55: Line 48:
data.g = g
data.g = g
data.sg = ""
data.sg = ""
data.pau = matche(wordpron(word), "[eiøy]") and "ч"
data.pau = wordpron(word):match("[eiøy]ː?$") and "ч"
  or matche(wordpron(word), "[ɛa]") and "н"
  or wordpron(word):match("[ɛa]ː?$") and "н"
  or matche(wordpron(word), "[uoɔ]") and "ӈ"
  or wordpron(word):match("[uoɔ]ː?$") and "ӈ"
  or gsubh("Bӈ","о̆","э̆",nil,nil,"о̆")
  or gsubh("Bӈ","о̆","э̆",nil,nil,"о̆")
data.pl = {
data.pl = {
["i"] = matche(wordpron(word), voiceless) and gsubh("фBд","ө","э",nil,nil,"э") or gsubh("вBд","ө","э",nil,nil,"э"),
["i"] = wordpron(word);match(voiceless .. "ː?$") and gsubh("фBд","ө","э",nil,nil,"э") or gsubh("вBд","ө","э",nil,nil,"э"),
["a"] = matche(wordpron(word), voiceless) and gsubh("шBд","о̆","э̆",nil,nil,"о̆") or gsubh("жBд","о̆","э̆",nil,nil,"о̆"),
["a"] = wordpron(word);match(voiceless .. "ː?$") and gsubh("шBд","о̆","э̆",nil,nil,"о̆") or gsubh("жBд","о̆","э̆",nil,nil,"о̆"),
}
}
Line 116: Line 109:
local decl = {
local decl = {
["nom"] = "",
["nom"] = "",
["acc"] = matche(w_number[n_sh], vowel) and "дза" or matche(w_number[n_sh], voiced) and "да" or "та",
["acc"] = w_number[n_sh]:match(vowel .. "ː?$") and "дза" or w_number[n_sh]:match(voiced .. "ː?$") and "да" or "та",
["dat"] = matche(w_number[n_sh], vowel) and "ша" or matche(w_number[n_sh], voiced) and "за" or "са",
["dat"] = w_number[n_sh]:match(vowel .. "ː?$") and "ша" or w_number[n_sh]:match(voiced .. "ː?$") and "за" or "са",
["gen"] = "ля",
["gen"] = "ля",
["ins"] = matche(w_number[n_sh], vowel) and "лза" or gsubh("Bлз","ө", "э", nil, nil, "ө"),
["ins"] = w_number[n_sh]:match(vowel .. "ː?$") and "лза" or gsubh("Bлз","ө", "э", nil, nil, "ө"),
["pro"] = gsubh("сBц","ө", "э", nil, nil, "ө"),
["pro"] = gsubh("сBц","ө", "э", nil, nil, "ө"),
["ade"] = "ляц",
["ade"] = "ляц",