モジュール:fy-adjectives
ナビゲーションに移動
検索に移動
このモジュールについての説明文ページを モジュール:fy-adjectives/doc に作成できます
local lang = require("モジュール:languages").getByCode("fy")
local export = {}
function export.adjective(frame)
local params = {
[1] = {},
[2] = {},
[3] = {},
["pred"] = {},
["part"] = {},
}
local args = require("モジュール:parameters").process(frame:getParent().args, params)
local make_auto_subtabler = require("モジュール:auto-subtable")
local data = {forms = make_auto_subtabler(), categories = {}, comparable = true}
-- Get parameters
local pred = args["pred"]
local infl = args[1]
local part = args["part"]
if args[2] == "-" then
data.comparable = false
end
local base = mw.title.getCurrentTitle().nsText == "テンプレート" and "-" or mw.title.getCurrentTitle().text
-- Positive degree
if pred == "-" then
pred = nil
elseif not pred then
pred = base
end
if not infl then
infl = base .. "e"
end
if part == "-" then
part = nil
elseif not part then
if base:find("s$") then
part = base
else
part = base .. "s"
end
end
data.forms["pred"] = {pred}
data.forms["indef|c|s"] = {infl}
data.forms["indef|n|s"] = {base}
data.forms["indef|p"] = {infl}
data.forms["def"] = {infl}
data.forms["par"] = {part}
if data.comparable then
-- Comparative degree
local comd_base = {args[2]}
if not comd_base[1] then
-- Adjectives ending in -r get an extra -d- in the comparative,
-- disregarding the inflected form.
if base:find("r$") then
comd_base = {base .. "der"}
-- Adjectives ending in -l or -n also get an extra -d-,
-- but it's optional alongside the form without it.
elseif base:find("[ln]$") then
comd_base = {base .. "der", infl .. "r"}
else
comd_base = {infl .. "r"}
end
end
for _, form in ipairs(comd_base) do
table.insert(data.forms["pred|comd"], form)
table.insert(data.forms["indef|n|s|comd"], form)
table.insert(data.forms["indef|c|s|comd"], form .. "e")
table.insert(data.forms["indef|p|comd"], form .. "e")
table.insert(data.forms["def|comd"], form .. "e")
table.insert(data.forms["par|comd"], form .. "s")
end
-- Superlative degree
local supd_base = {args[3]}
if not supd_base[1] then
if base:find("st$") then
supd_base = {base}
else
supd_base = {part .. "t"}
end
end
for _, form in ipairs(supd_base) do
table.insert(data.forms["pred|supd"], "it [[" .. form .. "]]")
table.insert(data.forms["pred|supd"], "it [[" .. form .. "e]]")
table.insert(data.forms["indef|c|s|supd"], form .. "e")
table.insert(data.forms["indef|n|s|supd"], form .. "e")
table.insert(data.forms["indef|p|supd"], form .. "e")
table.insert(data.forms["def|supd"], form .. "e")
end
end
-- Remove metatable.
data.forms:un_auto_subtable()
return make_table(data)
end
-- Make the table
function make_table(data)
local function repl(param)
local accel = true
local no_store = false
if param == "lemma" then
return require("モジュール:links").full_link({lang = lang, alt = mw.title.getCurrentTitle().text}, "term")
elseif param == "info" then
return data.title and " (" .. data.title .. ")" or ""
elseif string.sub(param, 1, 1) == "!" then
no_store = true
param = string.sub(param, 2)
elseif string.sub(param, 1, 1) == "#" then
accel = false
param = string.sub(param, 2)
end
local forms = data.forms[param]
if not forms then
return "—"
end
local ret = {}
for key, subform in ipairs(forms) do
table.insert(ret, require("モジュール:links").full_link({lang = lang, term = subform, accel = accel and {form = param, lemma = data.lemma, no_store = no_store} or nil}))
end
return table.concat(ret, "<br/>")
end
local wikicode = [=[
{| class="inflection-table vsSwitcher" data-toggle-category="inflection" style="border: 1px solid #CCCCFF;" cellspacing="1" cellpadding="3"
|- style="background: #CCCCFF;"
! colspan="5" class="vsToggleElement" style="text-align: left" | {{{lemma}}}{{{info}}}の語形変化
|- class="vsShow" style="background: #F2F2FF;"
! style="background: #CCCCFF;" | 原形
| style="min-width: 12em;" | {{{!indef|n|s}}}
|- class="vsShow" style="background: #F2F2FF;"
! style="background: #CCCCFF;" | 活用形
| {{{!indef|c|s}}}
|- class="vsShow" style="background: #F2F2FF;"
! style="background: #CCCCFF;" | 比較級
| {{{!indef|n|s|comd}}}
|- class="vsHide" style="background: #CCCCFF;"
| colspan="2" style="background: #E6E6FF;" |
! style="min-width: 12em;" | [[原級]]]=] .. (data.comparable and [=[
! style="min-width: 12em;" | [[比較級]]
! style="min-width: 12em;" | [[最上級]]]=] or "") .. [=[
|- class="vsHide" style="background: #F2F2FF;"
! style="background: #CCCCFF;" colspan="2" | [[叙述]]/[[副詞的語句]]
| {{{pred}}}]=] .. (data.comparable and " || {{{pred|comd}}} || {{{pred|supd}}}" or "") .. [=[
|- class="vsHide" style="background: #F2F2FF;"
! style="background: #CCCCFF;" rowspan="3" | [[非限定]]
! style="background: #CCCCFF;" | [[通性]][[単数]]
| {{{indef|c|s}}}]=] .. (data.comparable and " || {{{indef|c|s|comd}}} || {{{indef|c|s|supd}}}" or "") .. [=[
|- class="vsHide" style="background: #F2F2FF;"
! style="background: #CCCCFF;" | [[中性]][[単数]]
| {{{indef|n|s}}}]=] .. (data.comparable and " || {{{indef|n|s|comd}}} || {{{indef|n|s|supd}}}" or "") .. [=[
|- class="vsHide" style="background: #F2F2FF;"
! style="background:#CCCCFF;" | [[複数]]
| {{{indef|p}}}]=] .. (data.comparable and " || {{{indef|p|comd}}} || {{{indef|p|supd}}}" or "") .. [=[
|- class="vsHide" style="background: #F2F2FF;"
! style="background: #CCCCFF;" colspan="2" | [[限定]]
| {{{def}}}]=] .. (data.comparable and " || {{{def|comd}}} || {{{def|supd}}}" or "") .. [=[
|- class="vsHide" style="background: #F2F2FF;"
! style="background: #CCCCFF;" colspan="2" | [[部分語]]
| {{{par}}}]=] .. (data.comparable and " || {{{par|comd}}} || {{{par|supd}}}" or "") .. [=[
|}]=]
return mw.ustring.gsub(wikicode, "{{{([#!]?[a-z0-9|]+)}}}", repl) .. require("モジュール:utilities").format_categories(data.categories, lang)
end
return export