Module:qay-noun: Difference between revisions

No edit summary
No edit summary
 
(22 intermediate revisions by the same user not shown)
Line 20: Line 20:
local function detect_decl(word)
local function detect_decl(word)
if word:match("[aeiouy]$") then
if word:match("[aeiouy]$") then
return "v"
return "v", {word}
else
else
return "c"
return "c", {word}
end
end
end
end
Line 33: Line 33:
local decl = {}
local decl = {}
local g = NAMESPACE == "Template" and "in" or parent_args[1] or parent_args["g"]
local g = NAMESPACE == "Template" and "in" or parent_args[1] or parent_args["g"]
local word = NAMESPACE == "Template" and "bahis" or parent_args["word"] or PAGENAME
local word = NAMESPACE == "Template" and "bahis" or parent_args.word or PAGENAME
local args = {}
local args = {}
local decl_type = NAMESPACE == "Template" and "in_c" or sub(genders[parent_args[1]],1,2) .. "_" .. detect_decl(word) or parent_args["decl"]  
local decl_type = NAMESPACE == "Template" and "in_c" or sub(genders[parent_args[1]],1,2) .. "_" .. detect_decl(word) or parent_args["decl"]  
Line 40: Line 40:
if not m_data[word] then
if not m_data[word] then
if frame.args.decl then
decl_type = frame.args.decl
else
if parent_args.n and parent_args.c and parent_args[1] then
decl_type = parent_args.n .. "-" .. parent_args.c
numbers = {parent_args[1]}
else
decl_type, numbers = detect_decl(word, parent_args.n, parent_args.c, reanalyzed)
end
end
if not decl_type then
if not decl_type then
Line 45: Line 55:
end
end
args = require("Module:parameters").process(parent_args, m_data[decl_type].params, true)
args = require("Module:parameters").process(parent_args, m_data[sub(genders[parent_args[1]],1,2) .. "_" .. decl_type].params, true)
if numbers then
if numbers then
Line 57: Line 67:
data.head = parent_args["head"] or word
data.head = parent_args["head"] or word
data.whole_word = parent_args["word"] and true or false
data.proper = parent_args["proper"] and true or false
data.proper = parent_args["proper"] and true or false
data.nocat = parent_args["nocat"] and true or false
data.nocat = parent_args["nocat"] and true or false
data.g = genders[g]
data.g = genders[g]
data.nopl = parent_args["nopl"] and true or false
data.nopl = parent_args["nopl"] and true or false
data.pt = parent_args["pt"] and true or false --pluralia tantum
if data.proper then data.nopl = true end
if data.proper then data.nopl = true end
data.decl_type = decl_type
data.decl_type = decl_type
Line 68: Line 80:
m_data[word](parent_args, data)
m_data[word](parent_args, data)
else
else
m_data[decl_type](args, data)
m_data[sub(genders[parent_args[1]],1,2) .. "_" .. decl_type](args, data)
end
end
Line 93: Line 105:
local function link(term)
local function link(term)
local links = {}
local links = {}
for alt in gmatch(term, "([^%s,]+)") do
for alt in gmatch(term, "([^,]+)") do
alt = "[[Contionary:" .. alt .. "|" .. alt .. "]]"
alt = "[[Contionary:" .. alt .. "|" .. alt .. "]]"
table.insert(links, alt)
table.insert(links, alt)
Line 122: Line 134:
for _, case in ipairs(cases) do
for _, case in ipairs(cases) do
local case_short = sub(case, 1, 3)
local case_short = sub(case, 1, 3)
table.insert(ret, '|- \n! style="background-color:#FFF0DC" | ' .. case .. '\n')
table.insert(ret, '|- \n! style="background-color:#FFF0DC" width="30%" | ' .. case .. '\n')
table.insert(ret, '| ' .. link(show_form(data.forms[case_short .. '_s'])) .. '\n')
if not data.pt then
table.insert(ret, '| ' .. link(show_form(data.forms[case_short .. '_s'])) .. '\n')
end
if not data.nopl then
if not data.nopl then
table.insert(ret, '| ' .. link(show_form(data.forms[case_short .. '_p'])) .. '\n')
table.insert(ret, '| ' .. link(show_form(data.forms[case_short .. (data.pt and '_s' or '_p')])) .. '\n')
end
end
end
end
Line 132: Line 146:


local navframe = [=[
local navframe = [=[
<div class="mw-collapsible" style="border-collapse: collapse; margin: 0px 0px -1px 0px; padding: 2px; border: 1px solid #aaaaaa; text-align: center; font-size: 95%; overflow: auto; width: 55%;">
<div class="mw-collapsible" style="border-collapse: collapse; margin: 0px 0px -1px 0px; padding: 2px; border: 1px solid #aaaaaa; text-align: center; font-size: 95%; overflow: auto; width: 50%;">
<div style="min-height: 1.6em; font-weight:bold; font-size: 100%; text-align: left; background-color:#efefef; padding-left: 10px; background-image: -webkit-gradient(linear, left top, left bottom, from(#EFEFEF), to(#DFDFDF), color-stop(0.6, #E3E3E3)); background-image: -moz-linear-gradient(top, #EFEFEF, #E3E3E3 60%, #DFDFDF);  background-image: -o-linear-gradient(top, #EFEFEF, #E3E3E3 60%, #DFDFDF);">''{{{title}}}'' — {{{gender}}} noun ({{{decl_type}}})</div>
<div style="min-height: 1.6em; font-weight:bold; font-size: 100%; text-align: left; background-color:#efefef; padding-left: 10px; background-image: -webkit-gradient(linear, left top, left bottom, from(#EFEFEF), to(#DFDFDF), color-stop(0.6, #E3E3E3)); background-image: -moz-linear-gradient(top, #EFEFEF, #E3E3E3 60%, #DFDFDF);  background-image: -o-linear-gradient(top, #EFEFEF, #E3E3E3 60%, #DFDFDF);">''{{{title}}}'' — {{{gender}}} noun ({{{decl_type}}})</div>
<div class="mw-collapsible-content" style="font-size: 100%;">
<div class="mw-collapsible-content" style="font-size: 100%;">
Line 141: Line 155:
|-
|-
! &nbsp;
! &nbsp;
]=] .. (data.pt and "\n" or [=[
! style="background-color:#F4E6AC" | Singular
! style="background-color:#F4E6AC" | Singular
]=] .. (data.nopl and "\n" or [=[
]=]) .. (data.nopl and "\n" or [=[
! style="background-color:#F4E6AC" | Plural
! style="background-color:#F4E6AC" | Plural
]=]) .. make_cases(data) .. [=[
]=]) .. make_cases(data) .. [=[