10,735
edits
TheNightAvl (talk | contribs) mNo edit summary |
TheNightAvl (talk | contribs) No edit summary |
||
Line 88: | Line 88: | ||
end | end | ||
function rad_link_IPA(word, post, noipa) | function rad_link_IPA(word, post, noipa, pre) | ||
if noipa == nil then noipa = false end | if noipa == nil then noipa = false end | ||
local post_space = " " | local post_space = " " | ||
local pre_space = " " | |||
if post then | if post then | ||
if mw.ustring.sub(post, 1, 1) == "-" then | if mw.ustring.sub(post, 1, 1) == "-" then | ||
Line 97: | Line 98: | ||
else | else | ||
post_space = "" | post_space = "" | ||
end | |||
if pre then | |||
if mw.ustring.sub(pre, -1) == "-" then | |||
pre_space = "" | |||
end | |||
else | |||
pre_space = "" | |||
end | end | ||
if type(word) == "string" then | if type(word) == "string" then | ||
if noipa then | if noipa then | ||
local temp = rad_link(word) | |||
if post then temp = temp .. post_space .. rad_link(post) end | |||
if pre then temp = rad_link(pre) .. pre_space .. temp end | |||
return temp | |||
else | |||
local temp = rad_link(word) | |||
local ipa_temp = word | |||
if post then | if post then | ||
temp = temp .. post_space .. rad_link(post) | |||
ipa_temp = ipa_temp .. post_space .. post | |||
end | end | ||
if pre then | |||
if | temp = rad_link(pre) .. pre_space .. temp | ||
ipa_temp = pre .. pre_space .. ipa_temp | |||
end | end | ||
return temp .. "<br>" .. rad_IPA(ipa_temp) | |||
end | end | ||
elseif type(word) == "table" then | elseif type(word) == "table" then | ||
Line 119: | Line 132: | ||
local new_link = rad_link(i['word']) | local new_link = rad_link(i['word']) | ||
if post then new_link = new_link .. post_space .. rad_link(post) end | if post then new_link = new_link .. post_space .. rad_link(post) end | ||
if pre then new_link = rad_link(post) .. pre_space .. new_link end | |||
if i['note'] then new_link = new_link .. " <small>(" .. i['note'] .. ")</small>" end | if i['note'] then new_link = new_link .. " <small>(" .. i['note'] .. ")</small>" end | ||
table.insert(links, new_link) | table.insert(links, new_link) | ||
if not noipa then | if not noipa then | ||
local ipa_temp = i['word'] | |||
if post then | if post then | ||
ipa_temp = ipa_temp .. post_space .. post | |||
end | end | ||
if pre then | |||
ipa_temp = pre .. pre_space .. ipa_temp | |||
end | |||
table.insert(IPAs, rad_IPA(ipa_temp)) | |||
end | end | ||
end | end | ||
Line 136: | Line 153: | ||
else error("Incompatible input type for rad_link_IPA") | else error("Incompatible input type for rad_link_IPA") | ||
end | end | ||
end | |||
function export.compare(frame) | |||
local args = getArgs(frame) | |||
local lemma = mw.title.getCurrentTitle().text | |||
local pos = args[2] | |||
local stem = args[1] | |||
local disable_ipa = args['noipa'] or false | |||
if args[1] and args[2] ~= "adj" and args[2] ~= "adv" then error("First parameter must be adj or adv.") end | |||
-- process alts -- | |||
if args['alt'] then | |||
if stem == nil then error("You cannot have alternative forms of a nil stem.") end | |||
local stem_temp = { | |||
[1] = {word = args[1]}, | |||
[2] = {word = args['alt'], note = args['alt_note']} | |||
} | |||
local counter = 2 | |||
while args['alt' .. counter] do | |||
stem_temp[counter + 1] = {word = args['alt' .. counter], note = args['alt' .. counter .. '_note']} | |||
counter = counter + 1 | |||
end | |||
stem = stem_temp | |||
end | |||
local function get_forms(ending, pre) | |||
if stem == nil then | |||
return rad_link_IPA(lemma, nil, disable_ipa, pre) | |||
elseif type(stem) == "string" then | |||
return rad_link_IPA(stem .. ending, nil, disable_ipa) | |||
elseif type(stem) == "table" then | |||
for i, j in ipairs(stem) do | |||
stem[i]['word'] = j.word .. ending | |||
end | |||
return rad_link_IPA(stem, nil, disable_ipa) | |||
end | |||
end | |||
add("<table class=\"mw-collapsible mw-collapsed wikitable inflection table\" width=50% style=\"text-align: center\">") | |||
tr() | |||
th("Comparative forms of ''" .. lemma .. "'' ",1,2) | |||
_tr() | |||
th("degree") | |||
th("form") | |||
_tr() | |||
th("positive") | |||
td("'''" .. lemma .. "'''") | |||
_tr() | |||
th("comparative") | |||
if pos == "adj" then | |||
td(get_forms("uobș", "hevúb")) | |||
elseif pos == "adv" then | |||
td(get_forms("úb", "hevúb")) | |||
end | |||
_tr() | |||
th("superlative") | |||
if pos == "adj" then | |||
td(get_forms("úvaș", "hevúva")) | |||
elseif pos == "adv" then | |||
td(get_forms("úva", "hevúva")) | |||
end | |||
_tr() | |||
th("excessive") | |||
if pos == "adj" then | |||
td(get_forms("úvaiș", "hevúvai")) | |||
elseif pos == "adv" then | |||
td(get_forms("úvai", "hevúvai")) | |||
end | |||
tr_() | |||
add("</table>") | |||
return table.concat(format_table, string.char(10)) | |||
end | end | ||