Module:rad-stem: Difference between revisions

Heavy stems now functional
(Created page with "--WORK IN PROGRESS -- local export = {} local getArgs = require('Module:Arguments').getArgs local m_IPA = require("Module:rad-IPA") local m_links = require("Module:links") local m_languages = require("Module:languages") local m_parameters = require("Module:parameters") local V = "aáàâảeéèiíìỉoóòøuúùûūủyýỳỷ" local C = "bcdðfghħjĵkķlmnņpqrsștvwxzþ" local O = "bcdðfghħkķpqsștvxzþ" local O_voiced = "bdðgħvxz" local O_unvoiced =...")
 
(Heavy stems now functional)
Line 13: Line 13:
local V = "aáàâảeéèiíìỉoóòøuúùûūủyýỳỷ"
local V = "aáàâảeéèiíìỉoóòøuúùûūủyýỳỷ"
local C = "bcdðfghħjĵkķlmnņpqrsștvwxzþ"
local C = "bcdðfghħjĵkķlmnņpqrsștvwxzþ"
local O = "bcdðfghħkķpqsștvxzþ"
local O_voiced = "bdðgħvxz"
local O_voiced = "bdðgħvxz"
local O_unvoiced = "cfhkķpqsștþ"
local O_unvoiced = "cfhkķpqsștþ"
local O = O_voiced .. O_unvoiced
local N = "mnņ"
local N = "mnņ"
local L = "lr"
local L = "lr"
Line 58: Line 58:
end
end
end
end
-- resolve =g/=d
resolve("([rv])%=g","%1=u")
resolve("(j%=g)","j")
resolve("(j%=d)","x")
resolve("([pf]%=g)","f")
resolve("([pf]%=d)","f=t")
resolve("(g%=g)","g")
resolve("(k%=g)","k")
resolve("(k%=d)","t")
resolve("(m%=g)","n=g")
resolve("b%=([gd])","v=%1")
resolve("(j[ctþ]%=g)","ș=k")
resolve("(j[ctþ]%=d)","ș=t")
resolve("j[dð]%=([gd])","x=%1")
resolve("jdz%=([gd])","x=%1")
-- resolve phantom consonants --
resolve("([sș]?[șķ]%=g)","ș=k")
resolve("([sș]?[șķ]%=d)","ș=t")
resolve("[zx]?d?x%=([gd])","x=%1")
-- resolve =g
resolve("(s?[cstþ]%=g)","s=k")
resolve("([pf]%=g)","f")
resolve("(s?[cstþ]%=d)","s=t")
resolve("(b%=g)","vg")
resolve("(j[ctþ]%=g)","șk")
resolve("z?[zdð]%=([gd])","z=%1")
resolve("([sș]?[șķ]%=g)","șk")
resolve("z?dz%=([gd])","z=%1")
resolve("([șk]?[cstþ]%=g)","sk")
resolve("(s?[cstþ]%=g)","sk")
resolve("(v%=g)","vu")
resolve("([" .. C .. "])[mnņ]%=([gd])", "%1=%2")
-- resolve =s
-- resolve =s
resolve("([" .. C .. "])%=s","%1=s")
resolve("([sș])%=s","%1")
resolve("j%=s","ș")
-- resolve VvC
resolve("([^eoø])av%=([^" .. V .. "])","%1au=%2")
resolve("^av%=([^" .. V .. "])","au=%1")
resolve("(àv%=)","au=")
resolve("([^a])uv%=([^" .. V .. "])","%1ú=%2")
resolve("([^au])ov%=([^" .. V .. "])","%1ú=%2")
resolve("^[ou]v%=([^" .. V .. "])","ú=%1")
resolve("([òù]v%=)","ú=")
resolve("([^i])ev%=([^" .. V .. "])","%1ø=%2")
resolve("^ev%=([^" .. V .. "])","ø=%1")
resolve("(èv%=)","ø=")
resolve("([^aeuøâ])iv%=([^" .. V .. "])","%1y=%2")
resolve("^iv%=([^" .. V .. "])","y=%1")
resolve("(ìv%=)","y=")
-- resolve CvC
resolve("([" .. C .. "])v%=([" .. C .. "])","%1u=%2")
resolve("([" .. C .. "])v%=e","%1u=i")
-- resolve -ûve → -úe
resolve("ûv%=e", "ú=e")
-- resolve aja, ava
resolve("([^eoø])a[vj]%=a","%1á")
resolve("(à[vj]%=a)","á")
-- resolve f/þ~v/ð
resolve("([" .. V .. O .. L .. J .. "])f%=([" .. V .. J .. "])","%1v=%2")
resolve("([" .. V .. O .. L .. J .. "])þ%=([" .. V .. J .. "])","%1ð=%2")
-- resolve k/g + front vowel
resolve("k%=([ie])","c=%1")
resolve("g%=([ie])","dz=%1")
-- resolve vowels
-- resolve palatal + i
resolve("([^eo]av%=)","au")
resolve("([jșxķ])%=i","%1=e")
resolve("([^a]uv%=)","ú")
resolve("([^au]ov%=)","ú")
resolve("([^i]ev%=)","ø")
resolve("([^i]v%=)","ø")
-- resolve abbreviations
-- resolve =
resolve("(v%=g)","v")
resolve("(%=)","")
return resolution
return resolution
Line 101: Line 158:
local stem = ""
local stem = ""
local stem_broken = ""
local stem_broken = ""
local stem_broken_e = ""
local stem_raised = ""
local stem_raised = ""
local ending = ""
local ending = ""
Line 106: Line 164:
-- create stem and ending parameters --  
-- create stem and ending parameters --  
mw.log("Parameters:")
mw.log("Parameters:")
if stem_data[args[5]] == 'C' or stem_data[args[5]] or stem_data[args[6]] == 'C' or stem_data[args[6]] == 'CH' then
if stem_data[args[4]] == 'C' or stem_data[args[4]] or stem_data[args[5]] == 'C' or stem_data[args[5]] or stem_data[args[6]] == 'C' or stem_data[args[6]] == 'CH' then
if mw.ustring.find(args[4], "([%^%~])") then
if mw.ustring.find(args[4], "([%^])") then
local v_index = 4 -- expected nucleus position
stem = mw.ustring.match(args[4], "([^%^]+)%^") or ""
stem_raised = mw.ustring.match(args[4], "%^([^%^]+)")
while true do
if mw.ustring.find(args[v_index], "([%^%~])") then
if mw.ustring.find(args[v_index], "([%^])") then
stem = mw.ustring.match(args[v_index], "([^%^]+)%^") or ""
stem_raised = mw.ustring.match(args[v_index], "%^([^%^]+)")
else
stem = args[v_index]
stem_raised = args[v_index]
end
if mw.ustring.find(stem, "([%~])") then
stem_broken = mw.ustring.match(stem, "%~([^%~%^]+)")
stem = mw.ustring.match(stem, "([^%~]+)%~")
if stem_raised == args[v_index] then
stem_raised = stem_broken
end
else
stem_broken = stem
end
break
else
else
stem = args[4]
if mw.ustring.find(V, mw.ustring.sub(args[v_index], -1)) then
stem_raised = args[4]
stem = args[v_index]
end
stem_raised = stem
if mw.ustring.find(stem, "([%~])") then
stem_broken = stem
stem_broken = mw.ustring.match(stem, "%~([^%~%^]+)")
break
stem = mw.ustring.match(stem, "([^%~]+)%~")
elseif v_index == 3 then
if stem_raised == args[4] then
error()
stem_raised = stem_broken
else
v_index = 3
end
end
else
stem_broken = stem
end
end
end
if stem_broken == "u" then
stem_broken_e = "û"
else
else
error("The third parameter should contain a raised V^V or broken V~V stem.")
stem_broken_e = stem_broken
end
end
stem = args[3] .. stem .. args[5]
stem_broken = args[3] .. stem_broken .. args[5]
stem = stem .. args[v_index + 1]
stem_raised = args[3] .. stem_raised .. args[5]
stem_broken = stem_broken .. args[v_index + 1]
if args[6]~= nil then
stem_broken_e = stem_broken_e .. args[v_index + 1]
stem = stem .. args[6]
stem_raised = stem_raised .. args[v_index + 1]
stem_broken = stem_broken .. args[6]
if v_index > 3 then
stem_raised = stem_raised .. args[6]
stem = args[v_index - 1] .. stem
ending = args[6]
stem_broken = args[v_index - 1] .. stem_broken
stem_broken_e = args[v_index - 1] .. stem_broken_e
stem_raised = args[v_index - 1] .. stem_raised
end
if args[v_index + 2]~= nil then
stem = stem .. args[v_index + 2]
stem_broken = stem_broken .. args[v_index + 2]
stem_broken_e = stem_broken_e .. args[v_index + 2]
stem_raised = stem_raised .. args[v_index + 2]
ending = args[v_index + 2]
else
else
ending = args[5]
ending = args[v_index + 1]
end
end
elseif stem_data[args[4]] then
elseif stem_data[args[4]] then
Line 142: Line 230:
ending = args[4]
ending = args[4]
stem_broken = nil
stem_broken = nil
stem_broken_e = nil
stem_raised = nil
elseif stem_data[args[3]] then
stem = args[3]
ending = args[3]
stem_broken = nil
stem_broken_e = nil
stem_raised = nil
stem_raised = nil
else
else
Line 147: Line 242:
end
end
--
mw.log("Stem: " .. stem)
mw.log("Stem: " .. stem)
if stem_broken then mw.log("Broken stem: " .. stem_broken ) end
if stem_broken then mw.log("Broken stem: " .. stem_broken ) end
if stem_raised then mw.log("Raised stem: " .. stem_raised ) end
if stem_raised then mw.log("Raised stem: " .. stem_raised ) end
mw.log("Ending: " .. ending)
mw.log("Ending: " .. ending)
--
-- generate endings from declension type --
-- generate endings from declension type --
if stem_data[ending] == 'C' or stem_data[ending] == 'CH' then -- heavy stems
if stem_data[ending] == 'C' or stem_data[ending] == 'CH' then -- heavy stems
principle_parts["nom"] = stem_broken .. "=s"
if ending == "j" and not (mw.ustring.sub(stem, -2) == "oj" and mw.ustring.sub(stem, -3) ~= "aoj" and mw.ustring.sub(stem, -3) ~= "uoj") then
principle_parts["gen"] = stem_raised .. "=g"
principle_parts["nom"] = stem .. "=s"
principle_parts["acc"] = stem .. "=d"
else
principle_parts["nom"] = stem_broken .. "=s"
principle_parts["acc"] = stem_broken .. "=d"
end
if ending == 'v' and stem_raised == stem_broken then
principle_parts["gen"] = stem .. "=g"
else
principle_parts["gen"] = stem_raised .. "=g"
end
principle_parts["dat"] = stem .. "=a"
principle_parts["dat"] = stem .. "=a"
principle_parts["acc"] = stem_broken .. "=d"
principle_parts["ins"] = stem .. "=úr"
principle_parts["ins"] = stem .. "=úr"
principle_parts["nompl"] = stem_broken .. "=e"
principle_parts["nompl"] = stem_broken_e .. "=e"
principle_parts["genpl"] = stem .. "=i"
principle_parts["genpl"] = stem .. "=i"
principle_parts["genpl_short"] = principle_parts["genpl"]
principle_parts["genpl_short"] = principle_parts["genpl"]
Line 208: Line 314:
Debug console test string:
Debug console test string:
=p.getStem(mw.getCurrentFrame():newChild{title="whatever",args={"noun", "nom", "dv", "a^u", "n", "þ"}})
=p.getStem(mw.getCurrentFrame():newChild{title="whatever",args={"noun", "nom", "dv", "a^u", "n", "þ"}})
]]
]]--