コンテンツにスキップ

モジュール:lld-conj

出典: フリー多機能辞典『ウィクショナリー日本語版(Wiktionary)』

このモジュールについての説明文ページを モジュール:lld-conj/doc に作成できます

local m_links = require("モジュール:links")
local m_utilities = require("モジュール:utilities")

local m_infl =  require("モジュール:lld-conj/data")

local lang = require("モジュール:languages").getByCode("lld")

local export = {}

-- Shows forms with links, or a dash if empty
local function show_form(subforms)
	if not subforms then
		return "—"
	elseif type(subforms) ~= "table" then
		error("a non-table value was given in the list of inflected forms.")
	elseif #subforms == 0 then
		return "—"
	end
	
	local ret = {}
	
	-- Go over each subform and insert links
	for key, subform in ipairs(subforms) do
		table.insert(ret, m_links.full_link({lang = lang, term = subform}))
	end
	
	return table.concat(ret, ", ")
end

-- Shows the table with the given forms
local function make_table(data)
	local ret = {[=[* ラディン語の活用は地域によって様々なので以下の活用は典型的なもので、網羅している訳ではない。
<div class="NavFrame" style="clear:both; margin-top:1em">
<div class="NavHead" style="text-align: left"> ]=]}
	table.insert(ret, m_links.full_link({lang = lang, alt = mw.title.getCurrentTitle().text}, "term") .. " (" .. data.conj ..  ")の活用</div>\n")
	table.insert(ret, [=[<div class="NavContent">
{| style="background:#F0F0F0;border-collapse:separate;border-spacing:2px;width:100%" class="inflection-table"
|-
! colspan="1" style="background:#e2e4c0" | 不定詞
| colspan="1" | ]=])
	table.insert(ret, show_form(data.forms.inf) .. "\n")
	table.insert(ret, [=[
|-
! colspan="2" style="background:#e2e4c0" | 助動詞
| colspan="1" | ]=])
	table.insert(ret, show_form(data.forms.aux) .. "\n")
	table.insert(ret, [=[
! colspan="2" style="background:#e2e4c0" | 現在分詞
| colspan="2" | ]=])
	table.insert(ret, show_form(data.forms.gerund) .. "\n")
	table.insert(ret, [=[
|-
! colspan="2" style="background:#e2e4c0" | 過去分詞
| colspan="2" | ]=])
	table.insert(ret, show_form(data.forms.past_part) .. "\n")
	table.insert(ret, [=[
|-
! colspan="1" rowspan="2" style="background:#C0C0C0" | 人称
! colspan="3" style="background:#C0C0C0" | 単数
! colspan="3" style="background:#C0C0C0" | 複数

|-
! style="background:#C0C0C0;width:12.5%" | 一人称
! style="background:#C0C0C0;width:12.5%" | 二人称
! style="background:#C0C0C0;width:12.5%" | 三人称
! style="background:#C0C0C0;width:12.5%" | 一人称
! style="background:#C0C0C0;width:12.5%" | 二人称
! style="background:#C0C0C0;width:12.5%" | 三人称

|-
! style="background:#c0cfe4" colspan="1" | 直説法
! style="background:#c0cfe4" | ie
! style="background:#c0cfe4" | tu 
! style="background:#c0cfe4" | el / ela 
! style="background:#c0cfe4" | nos
! style="background:#c0cfe4" | vos
! style="background:#c0cfe4" | ei / eles

|-

! style="height:3em;background:#c0cfe4" colspan="1" | 現在
]=])
	table.insert(ret, "| " .. show_form(data.forms.pres_ind_1sg) .. "\n")
	table.insert(ret, "| " .. show_form(data.forms.pres_ind_2sg) .. "\n")
	table.insert(ret, "| " .. show_form(data.forms.pres_ind_3sg) .. "\n")
	table.insert(ret, "| " .. show_form(data.forms.pres_ind_1pl) .. "\n")
	table.insert(ret, "| " .. show_form(data.forms.pres_ind_2pl) .. "\n")
	table.insert(ret, "| " .. show_form(data.forms.pres_ind_3pl) .. "\n")
	table.insert(ret, [=[
|-
! style="height:3em;background:#c0cfe4" colspan="1" | 未完了
]=])
	table.insert(ret, "| " .. show_form(data.forms.impf_ind_1sg) .. "\n")
	table.insert(ret, "| " .. show_form(data.forms.impf_ind_2sg) .. "\n")
	table.insert(ret, "| " .. show_form(data.forms.impf_ind_3sg) .. "\n")
	table.insert(ret, "| " .. show_form(data.forms.impf_ind_1pl) .. "\n")
	table.insert(ret, "| " .. show_form(data.forms.impf_ind_2pl) .. "\n")
	table.insert(ret, "| " .. show_form(data.forms.impf_ind_3pl) .. "\n")
	table.insert(ret, [=[
|-
! style="height:3em;background:#c0cfe4" colspan="1" | 未来
]=])
	table.insert(ret, "| " .. show_form(data.forms.futr_ind_1sg) .. "\n")
	table.insert(ret, "| " .. show_form(data.forms.futr_ind_2sg) .. "\n")
	table.insert(ret, "| " .. show_form(data.forms.futr_ind_3sg) .. "\n")
	table.insert(ret, "| " .. show_form(data.forms.futr_ind_1pl) .. "\n")
	table.insert(ret, "| " .. show_form(data.forms.futr_ind_2pl) .. "\n")
	table.insert(ret, "| " .. show_form(data.forms.futr_ind_3pl) .. "\n")
	table.insert(ret, [=[
|-
! style="background:#c0e4c0" colspan="1" | 接続法
! style="background:#c0e4c0" | che ie
! style="background:#c0e4c0" | che tu
! style="background:#c0e4c0" | che el / ela
! style="background:#c0e4c0" | che nos
! style="background:#c0e4c0" | che vos
! style="background:#c0e4c0" | che ei / eles
|-
! style="height:3em;background:#c0e4c0" colspan="1" | 現在
]=])
	table.insert(ret, "| " .. show_form(data.forms.pres_sub_1sg) .. "\n")
	table.insert(ret, "| " .. show_form(data.forms.pres_sub_2sg) .. "\n")
	table.insert(ret, "| " .. show_form(data.forms.pres_sub_3sg) .. "\n")
	table.insert(ret, "| " .. show_form(data.forms.pres_sub_1pl) .. "\n")
	table.insert(ret, "| " .. show_form(data.forms.pres_sub_2pl) .. "\n")
	table.insert(ret, "| " .. show_form(data.forms.pres_sub_3pl) .. "\n")
	table.insert(ret, [=[
|-
! style="height:3em;background:#c0e4c0" colspan="1" | 未完了
]=])
	table.insert(ret, "| " .. show_form(data.forms.impf_sub_1sg) .. "\n")
	table.insert(ret, "| " .. show_form(data.forms.impf_sub_2sg) .. "\n")
	table.insert(ret, "| " .. show_form(data.forms.impf_sub_3sg) .. "\n")
	table.insert(ret, "| " .. show_form(data.forms.impf_sub_1pl) .. "\n")
	table.insert(ret, "| " .. show_form(data.forms.impf_sub_2pl) .. "\n")
	table.insert(ret, "| " .. show_form(data.forms.impf_sub_3pl) .. "\n")
	table.insert(ret, [=[
|-
! colspan="1" rowspan="2" style="height:3em;background:#e4d4c0" | 命令法
! style="background:#e4d4c0" | –
! style="background:#e4d4c0" | tu
! style="background:#e4d4c0" | –
! style="background:#e4d4c0" | nos
! style="background:#e4d4c0" | vos
! style="background:#e4d4c0" | –
|-
| —
]=])
	table.insert(ret, "| " .. show_form(data.forms.impr_2sg) .. "\n")
	table.insert(ret, "| —\n")
	table.insert(ret, "| " .. show_form(data.forms.impr_1pl) .. "\n")
	table.insert(ret, "| " .. show_form(data.forms.impr_2pl) .. "\n")
	table.insert(ret, "| —\n")
	table.insert(ret, [=[
|}
</div></div>]=])

	return table.concat(ret)
end

-- Main entry point
function export.show(frame)
	local args = mw.clone(frame:getParent().args)
	
	-- Create the forms
	local data = {forms = {}, categories = {}}
	
	if mw.title.getCurrentTitle().nsText ~= "" then return end
	
	local word = mw.title.getCurrentTitle().text
	
	if m_infl[word] then
		args[1] = m_infl[word].get_stem(word)
		m_infl[word](args, data)
	elseif mw.ustring.sub(word, -2, -1) == "ir" then
		args[1] = m_infl["ir"].get_stem(word)
		m_infl["ir"](args, data)
	else
		local conj = frame.args["conj"]
		if m_infl[conj] then
			m_infl[conj](args, data)
		else
			error("" .. word .. "の活用が見つかりません")
		end
	end
	
	return make_table(data) .. m_utilities.format_categories(data.categories, lang)
end

return export