Module:rad-stem/templates: Difference between revisions

ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
No edit summary
No edit summary
Line 245: Line 245:
['type'] = stem_gen['type'],
['type'] = stem_gen['type'],
}
}
local gender = args['gender'] or args['g'] or "in"
local definite = args['definite'] ~= nil or args['def'] ~= nil
local adj = args['adj']
local adj = args['adj']
local adj_broken = ""
local adj_broken = ""
local adj_broken_e = ""
local adj_broken_e = ""
if definite and adj then
if not (mw.ustring.match(mw.ustring.lower(adj), "^( ?[ui] )") or mw.ustring.match(mw.ustring.lower(adj), "^( ?a [iíỉuúủ])") or mw.ustring.match(mw.ustring.lower(adj), "^( ?a [" .. C .. "])") or mw.ustring.match(adj, "^( ?ag )")) then
if gender == "in" then
if mw.ustring.match(mw.ustring.lower(adj), "^([" .. C .. "])") then
adj = " a " .. adj
else
adj = " ag " .. adj
end
elseif gender == "an" then
if mw.ustring.match(mw.ustring.lower(adj), "^([uúủ])") then
adj = " a " .. adj
else
adj = " u " .. adj
end
end
end
end
if adj then
if adj then
if not mw.ustring.match(adj, "(ș)$") then error("All adjectives must end in -ș") end
if not mw.ustring.match(adj, "(ș)$") then error("All adjectives must end in -ș") end
Line 280: Line 303:
local table_type = args['type'] or args['t'] or "sgpl"
local table_type = args['type'] or args['t'] or "sgpl"
local gender = args['gender'] or args['g'] or "in"
local oblique_pl = {['genpl'] = true, ['datpl'] = true, ['accpl'] = true, ['inspl'] = true, ['gendu'] = true, ['datdu'] = true, ['accdu'] = true, ['insdu'] = true,}
local pl = {['nompl'] = true, ['genpl'] = true, ['datpl'] = true, ['accpl'] = true, ['inspl'] = true, ['nomdu'] = true, ['gendu'] = true, ['datdu'] = true, ['accdu'] = true, ['insdu'] = true,}
-- generate forms --
-- generate forms --
local function get_forms(case, base, adj_base, adj_ending, nolink)
local function get_forms(case, base, adj_base, adj_ending, nolink)
local article = ""
if adj_base then
if adj_base then
--adjust definite article --
--adjust definite article --
local oblique_pl = {['genpl'] = true, ['datpl'] = true, ['accpl'] = true, ['inspl'] = true, ['gendu'] = true, ['datdu'] = true, ['accdu'] = true, ['insdu'] = true,}
-- detect inanimate --
-- detect inanimate --
if mw.ustring.match(mw.ustring.lower(adj_base), "^( ?a [" .. C .. "])") or mw.ustring.match(adj_base, "^( ag )") then
if mw.ustring.match(mw.ustring.lower(adj_base), "^( ?a [" .. C .. "])") or mw.ustring.match(adj_base, "^( ?ag )") then
definite = true
if oblique_pl[case] then
if oblique_pl[case] then
adj_base = mw.ustring.gsub(adj_base, "^( ?)ag ([iíỉIÍỈ])", "%1a’ %2")
adj_base = mw.ustring.gsub(adj_base, "^( ?)ag ([iíỉIÍỈ])", "%1a' %2")
adj_base = mw.ustring.gsub(adj_base, "^( ?)ag? ", "%1ai ")
adj_base = mw.ustring.gsub(adj_base, "^( ?)ag? ", "%1ai ")
elseif case == "genpl_short" or case == "gendu_short" then
elseif case == "genpl_short" or case == "gendu_short" then
adj_base = mw.ustring.gsub(adj_base, "^( ?)ag? ", "%1ais ")
adj_base = mw.ustring.gsub(adj_base, "^( ?)ag? ", "%1ais ")
elseif case == "gen_short" then
adj_base = mw.ustring.gsub(adj_base, "^( ?)ag? ", "%1as ")
case = "gen"
end
-- detect animate --
elseif mw.ustring.match(mw.ustring.lower(adj_base), "^( ?[ui] )") or mw.ustring.match(adj_base, "^( ?a [iíỉuúủIÍỈUÚỦ])") then
definite = true
if pl[case] then
adj_base = mw.ustring.gsub(adj_base, "^( ?)[au] ([iíỉIÍỈ])", "%1a %2")
adj_base = mw.ustring.gsub(adj_base, "^( ?)[au] ", "%1i ")
elseif case == "genpl_short" or case == "gendu_short" then
adj_base = mw.ustring.gsub(adj_base, "^( ?)[aiu] ", "%1is ")
elseif case == "gen_short" then
adj_base = mw.ustring.gsub(adj_base, "^( ?)[aiu] ", "%1us ")
case = "gen"
end
end
end
end
Line 301: Line 342:
base = base .. adj_base
base = base .. adj_base
if adj_ending then base = base .. adj_ending end
if adj_ending then base = base .. adj_ending end
elseif definite then -- if not adjective but definite
local c_initial = mw.ustring.match(mw.ustring.lower(base), "^([" .. C .. "])")
local i_initial = mw.ustring.match(mw.ustring.lower(base), "^([iíỉ])")
local u_initial = mw.ustring.match(mw.ustring.lower(base), "^([uúủ])")
if gender == "in" then
if oblique_pl[case] then
if i_initial then
article = "a'"
else
article = "ai"
end
elseif case == "gen_short" then
article = "as"
case = "gen"
elseif case == "genpl_short" or case == "gendu_short" then
article = "ais"
else
if c_initial then
article = "ag"
else
article = "a"
end
end
else -- animate definite article
if pl[case] then
if i_initial then
article = "a"
else
article = "i"
end
elseif case == "gen_short" then
article = "us"
case = "gen"
elseif case == "genpl_short" or case == "gendu_short" then
article = "is"
else
if u_initial then
article = "a"
else
article = "u"
end
end
end
if nolink then
article = article .. " "
else
article = "'''" .. rad_link(article) .. "''' "
end
end
end
if post then base = base .. post end
if post then base = base .. post end
Line 325: Line 414:
end
end
if nolink then
if nolink then
return list[1].word
return article .. list[1].word
else
else
if disable_ipa then return rad_link_IPA(list, nil, true) else return rad_link_IPA(list) end
if disable_ipa then return article .. rad_link_IPA(list, nil, true) else return article .. rad_link_IPA(list) end
end
end
else
else
if nolink then
if nolink then
return base
return article .. base
else
else
if disable_ipa then return rad_link_IPA(base, nil, true) else return rad_link_IPA(base) end
if disable_ipa then return article .. rad_link_IPA(base, nil, true) else return article .. rad_link_IPA(base) end
end
end
end
end