モジュール:日本語活用表

このモジュールについての説明文ページを モジュール:日本語活用表/doc に作成できます

local m_ja = require("モジュール:ja")
local m_strutil = require("モジュール:string utilities")
local lang = require("Module:languages").getByCode("ja")

local export = {}
local pos_functions = {}

local function create_stem_form_table(data)
	local function get_gobi(form)
		-- 学校文法では活用語尾が無いことはありえないので、空文字列はnilと同じと思って良いはず。
		if form and form ~= "" then
			return type(form) ~= "table" and form or table.concat(form, '<br />')
		else
			return "(無し)"
		end
	end

	local template = [===[{\op}| class="wikitable" style="text-align:center"
|+ {kihon} {pos}活用表<small>([[付録:日本語の活用|日本語の活用]])</small>
]===] .. (data.class ~= "" and '! colspan="7" | [[{class}|{gyou}{class}]]\n' or '') ..
[===[|-
! [[語幹]] !! [[未然形]] !! [[連用形]] !! [[終止形]] !! [[連体形]] !! [[仮定形]] !! [[命令形]]
|-
| {gokan} || {mizen} || {renyou} || {shuushi} || {rentai} || {katei} || {meirei}
|{\cl}]===]

	local values = {
		pos = data.pos,
		gyou = data.gyou,
		class = data.class,
		gokan = data.gokan ~= "" and data.gokan or "(語幹無し)",
		-- 語幹と語尾両方あればハイフンで繫ぐ。片方でもなければ片方だけ表示する(この場合は単に文字列結合すれば片方だけが表示される)。
		kihon = (data.gokan ~= "" and data.gobi.kihon ~= "") and (data.gokan .. '-' .. data.gobi.kihon) or (data.gokan .. data.gobi.kihon),
		mizen = get_gobi(data.gobi.mizen),
		renyou = get_gobi(data.gobi.renyou),
		shuushi = get_gobi(data.gobi.shuushi),
		rentai = get_gobi(data.gobi.rentai),
		katei = get_gobi(data.gobi.katei),
		meirei = get_gobi(data.gobi.meirei)
	}

	return m_strutil.format(template, values)
end

local function create_key_construction_table(data)
	local result = {}
	table.insert(result, [=[{| class="wikitable" style="text-align:center"
|+ 各活用形の基礎的な結合例
! 意味 !! 語形 !! 結合
]=])

	for _, v in ipairs(data) do
		local row = '|-\n'
		.. '| ' .. v.imi
		.. ' || ' .. (type(v.gokei) ~= "table" and v.gokei or table.concat(v.gokei, '<br />'))
		.. ' || ' .. v.ketsugou
		table.insert(result, row)
	end

	table.insert(result, '|}')

	return table.concat(result, '\n')
end

pos_functions["動詞"] = function(data, categories)
	local function godan(data, categories)
		local GOBI_TO_GYOU = {
			["う"] = "ワ行",
			["く"] = "カ行",
			["ぐ"] = "ガ行",
			["す"] = "サ行",
			["ず"] = "ザ行",
			["つ"] = "タ行",
			["づ"] = "ダ行",
			["ぬ"] = "ナ行",
			["ふ"] = "ハ行",
			["ぶ"] = "バ行",
			["ぷ"] = "パ行",
			["む"] = "マ行",
			["ゆ"] = "ヤ行",
			["る"] = "ラ行"
		}
		local GOBI_TO_KATSUYOU = {
			["う"] = {mizen={hitei="わ", ishi="お"}, renyou={teinei="い", kako="っ"}, shuushi="う", rentai="う", katei="え", meirei="え", jodoushi={kako="た"}},
			["く"] = {mizen={hitei="か", ishi="こ"}, renyou={teinei="き", kako="い"}, shuushi="く", rentai="く", katei="け", meirei="け", jodoushi={kako="た"}},
			["ぐ"] = {mizen={hitei="が", ishi="ご"}, renyou={teinei="ぎ", kako="い"}, shuushi="ぐ", rentai="ぐ", katei="げ", meirei="げ", jodoushi={kako="だ"}},
			["す"] = {mizen={hitei="さ", ishi="そ"}, renyou={teinei="し", kako="し"}, shuushi="す", rentai="す", katei="せ", meirei="せ", jodoushi={kako="た"}},
			["つ"] = {mizen={hitei="た", ishi="と"}, renyou={teinei="ち", kako="っ"}, shuushi="つ", rentai="つ", katei="て", meirei="て", jodoushi={kako="た"}},
			["ぬ"] = {mizen={hitei="な", ishi="の"}, renyou={teinei="に", kako="ん"}, shuushi="ぬ", rentai="ぬ", katei="ね", meirei="ね", jodoushi={kako="だ"}},
			["ぶ"] = {mizen={hitei="ば", ishi="ぼ"}, renyou={teinei="び", kako="ん"}, shuushi="ぶ", rentai="ぶ", katei="べ", meirei="べ", jodoushi={kako="だ"}},
			["む"] = {mizen={hitei="ま", ishi="も"}, renyou={teinei="み", kako="ん"}, shuushi="む", rentai="む", katei="め", meirei="め", jodoushi={kako="だ"}},
			["る"] = {mizen={hitei="ら", ishi="ろ"}, renyou={teinei="り", kako="っ"}, shuushi="る", rentai="る", katei="れ", meirei="れ", jodoushi={kako="た"}}
		}
		local gokan
		local gobi
		gokan, gobi = mw.ustring.match(data.term, "^(.*)([うくぐすずつづぬふぶぷむゆる])$")
		if not (gokan and gobi) then
			error("活用タイプと語の形が合っていません。")
		end

		-- TODO: 本当はこうしたい、というコードをコメントアウトし、テンプレート:inf-jaのスタイルに合わせたカテゴリ名称にしておく。
		--table.insert(categories, "日本語 動詞 " .. GOBI_TO_GYOU[gobi] .."五段活用")
		table.insert(categories, "日本語 動詞 " .. mw.ustring.gsub(GOBI_TO_GYOU[gobi], "行", "") .. "五")

		-- 活用テーブル表示用データを組み立てる。
		local stem_form_data = {gokan = gokan, pos = data.pos, gyou = GOBI_TO_GYOU[gobi], class = data.class}
		local key_construction_data
		if GOBI_TO_KATSUYOU[gobi] then
			stem_form_data.gobi = {
				kihon = gobi,
				mizen = {GOBI_TO_KATSUYOU[gobi].mizen.hitei, GOBI_TO_KATSUYOU[gobi].mizen.ishi},
				renyou = (GOBI_TO_KATSUYOU[gobi].renyou.teinei == GOBI_TO_KATSUYOU[gobi].renyou.kako) and
						GOBI_TO_KATSUYOU[gobi].renyou.teinei or
						{GOBI_TO_KATSUYOU[gobi].renyou.teinei, GOBI_TO_KATSUYOU[gobi].renyou.kako},
				shuushi = GOBI_TO_KATSUYOU[gobi].shuushi,
				rentai = GOBI_TO_KATSUYOU[gobi].rentai,
				katei = GOBI_TO_KATSUYOU[gobi].katei,
				meirei = GOBI_TO_KATSUYOU[gobi].meirei,
			}
			key_construction_data = {
				[1] = {
					imi = "否定",
					gokei = gokan .. GOBI_TO_KATSUYOU[gobi].mizen.hitei .. "ない",
					ketsugou = "未然形 + [[ない]]"
				},
				[2] = {
					imi = "意志・勧誘",
					gokei = gokan .. GOBI_TO_KATSUYOU[gobi].mizen.ishi .. "う",
					ketsugou = "未然形音便 + [[う]]"
				},
				[3] = {
					imi = "丁寧",
					gokei = gokan .. GOBI_TO_KATSUYOU[gobi].renyou.teinei .. "ます",
					ketsugou = "連用形 + [[ます]]"
				},
				[4] = {
					imi = "過去・完了・状態",
					gokei = gokan .. GOBI_TO_KATSUYOU[gobi].renyou.kako .. GOBI_TO_KATSUYOU[gobi].jodoushi.kako,
					ketsugou = "連用形音便 + [[" .. GOBI_TO_KATSUYOU[gobi].jodoushi.kako .. "]]"
				},
				[5] = {
					imi = "言い切り",
					gokei = gokan .. GOBI_TO_KATSUYOU[gobi].shuushi,
					ketsugou = "終止形のみ"
				},
				[6] = {
					imi = "名詞化",
					gokei = gokan .. GOBI_TO_KATSUYOU[gobi].rentai .. "こと",
					ketsugou = "連体形 + [[こと]]"
				},
				[7] = {
					imi = "仮定条件",
					gokei = gokan .. GOBI_TO_KATSUYOU[gobi].katei .. "ば",
					ketsugou = "仮定形 + [[ば]]"
				},
				[8] = {
					imi = "命令",
					gokei = gokan .. GOBI_TO_KATSUYOU[gobi].meirei,
					ketsugou = "命令形のみ"
				}
			}
		else
			-- 活用が不明のため空っぽのデータを渡す。
			stem_form_data.gobi = {kihon=gobi, mizen={}, renyou={}, shuushi={}, renyou={}, katei={}, meirei={}}
			key_construction_data = {}
		end

		-- 特殊活用がある語はデータを上書きする。
		if mw.ustring.find(data.term, "[い行]く$") then
			stem_form_data.gobi.renyou = {"き", "っ"}
			key_construction_data[4].gokei = gokan .. "った"
		elseif mw.ustring.find(data.term, "ゆく$") then
			-- 「ゆく」の連用形は普通の形なのだが、稀なため注記を付ける。
			stem_form_data.gobi.renyou = {"き", "い<small>(古)</small>"}	-- 注記まで一緒にしたデータを渡していいのか!?
			key_construction_data[4].gokei = gokan .. "いた<small>(古)</small>"
		elseif mw.ustring.find(data.term, "いとう$") then
			stem_form_data.gobi.renyou = {"い", "っ", "う"}
			key_construction_data[4].gokei = {gokan .. "った", gokan .. "うた"}
		elseif mw.ustring.find(data.term, "なさる$") or
				mw.ustring.find(data.term, "くださる$") or 
				mw.ustring.find(data.term, "おっしゃる$") or 
				mw.ustring.find(data.term, "いらっしゃる$") then
			stem_form_data.gobi.renyou = {"り", "い", "っ"}
			stem_form_data.gobi.meirei = {"れ", "い"}
			key_construction_data[3].gokei = {gokan .. "ります", gokan .. "います"}
			key_construction_data[8].gokei = {gokan .. "れ", gokan .. "い"}
		elseif mw.ustring.find(data.term, "ござる$") then
			stem_form_data.gobi.renyou = {"り", "い", "っ"}
			key_construction_data[3].gokei = {gokan .. "ります", gokan .. "います"}
		end

		return create_stem_form_table(stem_form_data) .. '\n' .. create_key_construction_table(key_construction_data)
	end

	local function ichidan(data, categories)
		local GOKAN2_TO_GYOU = {
			["い"] = "ア行",
			["え"] = "ア行",
			["き"] = "カ行",
			["け"] = "カ行",
			["ぎ"] = "ガ行",
			["げ"] = "ガ行",
			["し"] = "サ行",
			["せ"] = "サ行",
			["じ"] = "ザ行",
			["ぜ"] = "ザ行",
			["ち"] = "タ行",
			["て"] = "タ行",
			["ぢ"] = "ダ行",
			["で"] = "ダ行",
			["に"] = "ナ行",
			["ね"] = "ナ行",
			["ひ"] = "ハ行",
			["へ"] = "ハ行",
			["び"] = "バ行",
			["べ"] = "バ行",
			["ぴ"] = "パ行",
			["ぺ"] = "パ行",
			["み"] = "マ行",
			["め"] = "マ行",
			["り"] = "ラ行",
			["れ"] = "ラ行"
		}
		local gokan1
		local gokan2
		local gobi

		-- 学校文法に対応するため一旦「あわ-て-る」の形に分ける。
		gokan1, gokan2, gobi = mw.ustring.match(data.term, "^(.*)([いきぎしじちぢにひびぴみりえけげせぜてでねへべぺめれ])([る])$")
		if not (gokan1 and gokan2 and gobi) then
			error("活用タイプと語の形が合っていません。")
		end
		-- 結合例の表示のためには「あわて-る」と区切るとやりやすい。
		local gokan = gokan1 .. gokan2

		if mw.ustring.find(gokan2, "[いきぎしじちぢにひびぴみり]") then
			data.class = "上一段活用"
		elseif mw.ustring.find(gokan2, "[えけげせぜてでねへべぺめれ]") then
			data.class = "下一段活用"
		end
		-- TODO: 本当はこうしたい、というコードをコメントアウトし、テンプレート:inf-jaのスタイルに合わせたカテゴリ名称にしておく。
		--table.insert(categories, "日本語 動詞 " .. GOKAN2_TO_GYOU[gokan2] .. data.class)
		table.insert(categories, "日本語 動詞 " .. mw.ustring.gsub(GOKAN2_TO_GYOU[gokan2], "行", "") .. mw.ustring.gsub(data.class, "段活用", ""))

		-- 活用テーブル表示用データを組み立てる。
		local stem_form_data = {gokan = gokan1, pos = data.pos, gyou = GOKAN2_TO_GYOU[gokan2], class = data.class}
		local key_construction_data
		stem_form_data.gobi = {
			kihon = gokan2 .. gobi,
			mizen = gokan2,
			renyou = gokan2,
			shuushi = gokan2 .. "る",
			rentai = gokan2 .. "る",
			katei = gokan2 .. "れ",
			meirei = {gokan2 .. "ろ", gokan2 .. "よ"}
		}
		key_construction_data = {
			{
				imi = "否定",
				gokei = gokan .. "ない",
				ketsugou = "未然形 + [[ない]]"
			},
			{
				imi = "意志・勧誘",
				gokei = gokan .. "よう",
				ketsugou = "未然形 + [[よう]]"
			},
			{
				imi = "丁寧",
				gokei = gokan .. "ます",
				ketsugou = "連用形 + [[ます]]"
			},
			{
				imi = "過去・完了・状態",
				gokei = gokan .. "た",
				ketsugou = "連用形 + [[た]]"
			},
			{
				imi = "言い切り",
				gokei = gokan .. "る",
				ketsugou = "終止形のみ"
			},
			{
				imi = "名詞化",
				gokei = gokan .. "ること",
				ketsugou = "連体形 + [[こと]]"
			},
			{
				imi = "仮定条件",
				gokei = gokan .. "れば",
				ketsugou = "仮定形 + [[ば]]"
			},
			{
				imi = "命令",
				gokei = {gokan .. "ろ", gokan .. "よ"},
				ketsugou = "命令形のみ"
			}
		}

		return create_stem_form_table(stem_form_data) .. '\n' .. create_key_construction_table(key_construction_data)
	end

	local function kahen(data, categories)
		local gokan
		local gobi
		-- 語尾に漢字を使って「来る」としても大丈夫だが、活用形の表示では無視して平仮名で書いてしまう。
		-- 当面は漢字表記の項目にカ変動詞活用表を置くことはなさそうなので、特別な対応はしないで済ませる。
		gokan, gobi = mw.ustring.match(data.term, "^(.*)([く来]る)$")
		if not (gokan and gobi) then
			error("活用タイプと語の形が合っていません。")
		end

		-- TODO: 本当はこうしたい、というコードをコメントアウトし、テンプレート:inf-jaのスタイルに合わせたカテゴリ名称にしておく。
		--table.insert(categories, "日本語 動詞 カ行変格活用")
		table.insert(categories, "日本語 動詞 カ変")

		-- 活用テーブル表示用データを組み立てる。
		local stem_form_data = {gokan = gokan, pos = data.pos, gyou = "カ行", class = "変格活用"}
		local key_construction_data
		stem_form_data.gobi = {
			kihon = gobi,
			mizen = "こ",
			renyou = "き",
			shuushi = "くる",
			rentai = "くる",
			katei = "くれ",
			meirei = "こい"
		}
		key_construction_data = {
			{
				imi = "否定",
				gokei = gokan .. "こない",
				ketsugou = "未然形 + [[ない]]"
			},
			{
				imi = "否定(古風)",
				gokei = gokan .. "こず",
				ketsugou = "未然形 + [[ず]]"
			},
			{
				imi = "自発・受身<br />可能・尊敬",
				gokei = gokan .. "こられる",
				ketsugou = "未然形 + [[られる]]"
			},
			{
				imi = "丁寧",
				gokei = gokan .. "きます",
				ketsugou = "連用形 + [[ます]]"
			},
			{
				imi = "過去・完了・状態",
				gokei = gokan .. "きた",
				ketsugou = "連用形 + [[た]]"
			},
			{
				imi = "言い切り",
				gokei = gokan .. "くる",
				ketsugou = "終止形のみ"
			},
			{
				imi = "名詞化",
				gokei = gokan .. "くること",
				ketsugou = "連体形 + [[こと]]"
			},
			{
				imi = "仮定条件",
				gokei = gokan .. "くれば",
				ketsugou = "仮定形 + [[ば]]"
			},
			{
				imi = "命令",
				gokei = gokan .. "こい",
				ketsugou = "命令形のみ"
			}
		}

		return create_stem_form_table(stem_form_data) .. '\n' .. create_key_construction_table(key_construction_data)
	end

	local function sahen(data, categories)
		local gokan
		local gobi

		gokan, gobi = mw.ustring.match(data.term, "^(.*)(する)$")
		if not (gokan and gobi) then
			gokan = data.term
			gobi = "する"
		end
		
		local gokan_kana = mw.ustring.gsub(data.kana, "する$", "")

		-- TODO: 本当はこうしたい、というコードをコメントアウトし、テンプレート:inf-jaのスタイルに合わせたカテゴリ名称にしておく。
		--table.insert(categories, "日本語 動詞 サ行変格活用")
		table.insert(categories, "日本語 動詞 サ変")

		-- 活用テーブル表示用データを組み立てる。
		local stem_form_data = {gokan = gokan, pos = data.pos, gyou = "サ行", class = "変格活用"}
		local key_construction_data
		stem_form_data.gobi = {
			kihon = gobi,
			mizen = {"し", "せ", "さ"},
			renyou = "し",
			shuushi = "する",
			rentai = "する",
			katei = "すれ",
			meirei = {"しろ", "せよ"}
		}
		key_construction_data = {
			[1] = {
				imi = "否定",
				gokei = gokan .. "しない",
				ketsugou = "未然形 + [[ない]]"
			},
			[2] = {
				imi = "否定(古風)",
				gokei = gokan .. "せず",
				ketsugou = "未然形 + [[ず]]"
			},
			[3] = {
				imi = "自発・受身<br />可能・尊敬",
				gokei = gokan .. "される",
				ketsugou = "未然形 + [[れる]]"
			},
			[4] = {
				imi = "丁寧",
				gokei = gokan .. "します",
				ketsugou = "連用形 + [[ます]]"
			},
			[5] = {
				imi = "過去・完了・状態",
				gokei = gokan .. "した",
				ketsugou = "連用形 + [[た]]"
			},
			[6] = {
				imi = "言い切り",
				gokei = gokan .. "する",
				ketsugou = "終止形のみ"
			},
			[7] = {
				imi = "名詞化",
				gokei = gokan .. "すること",
				ketsugou = "連体形 + [[こと]]"
			},
			[8] = {
				imi = "仮定条件",
				gokei = gokan .. "すれば",
				ketsugou = "仮定形 + [[ば]]"
			},
			[9] = {
				imi = "命令",
				gokei = {gokan .. "しろ", gokan .. "せよ"},
				ketsugou = "命令形のみ"
			}
		}

		-- 語幹が漢字一文字で「○っする」と読むものは未然形に「さ」がない。
		if mw.ustring.len(gokan) == 1 and mw.ustring.sub(gokan_kana, -1) == "っ" then
			stem_form_data.gobi.mizen = {"し", "せ"}
			key_construction_data[3].gokei = gokan .. "せられる"
			key_construction_data[3].ketsugou = "未然形 + [[られる]]"
		end

		return create_stem_form_table(stem_form_data) .. '\n' .. create_key_construction_table(key_construction_data)
	end

	local function zahen(data, categories)
		local gokan
		local gobi

		gokan, gobi = mw.ustring.match(data.term, "^(.*)(ずる)$")
		if not (gokan and gobi) then
			gokan = data.term
			gobi = "ずる"
		end

		-- 表示する用語にはザ行変格活用というものはない。
		-- TODO: 本当はこうしたい、というコードをコメントアウトし、テンプレート:inf-jaのスタイルに合わせたカテゴリ名称にしておく。
		--table.insert(categories, "日本語 動詞 サ行変格活用")
		table.insert(categories, "日本語 動詞 サ変")

		-- 活用テーブル表示用データを組み立てる。
		local stem_form_data = {gokan = gokan, pos = data.pos, gyou = "サ行", class = "変格活用"}
		local key_construction_data
		stem_form_data.gobi = {
			kihon = gobi,
			mizen = {"じ", "ぜ"},
			renyou = "じ",
			shuushi = "ずる",
			rentai = "ずる",
			katei = "ずれ",
			meirei = {"じろ", "ぜよ"}
		}
		key_construction_data = {
			{
				imi = "否定",
				gokei = gokan .. "じない",
				ketsugou = "未然形 + [[ない]]"
			},
			{
				imi = "否定(古風)",
				gokei = gokan .. "ぜず",
				ketsugou = "未然形 + [[ず]]"
			},
			{
				imi = "自発・受身<br />可能・尊敬",
				gokei = gokan .. "ぜられる",
				ketsugou = "未然形 + [[られる]]"
			},
			{
				imi = "丁寧",
				gokei = gokan .. "じます",
				ketsugou = "連用形 + [[ます]]"
			},
			{
				imi = "過去・完了・状態",
				gokei = gokan .. "じた",
				ketsugou = "連用形 + [[た]]"
			},
			{
				imi = "言い切り",
				gokei = gokan .. "ずる",
				ketsugou = "終止形のみ"
			},
			{
				imi = "名詞化",
				gokei = gokan .. "ずること",
				ketsugou = "連体形 + [[こと]]"
			},
			{
				imi = "仮定条件",
				gokei = gokan .. "ずれば",
				ketsugou = "仮定形 + [[ば]]"
			},
			{
				imi = "命令",
				gokei = {gokan .. "じろ", gokan .. "ぜよ"},
				ketsugou = "命令形のみ"
			}
		}

		return create_stem_form_table(stem_form_data) .. '\n' .. create_key_construction_table(key_construction_data)
	end

	local result = ""

	if data.class == "五段活用" then
		result = godan(data, categories)
	elseif data.class == "一段活用" or data.class == "上一段活用" or data.class == "下一段活用" then
		result = ichidan(data, categories)
	elseif data.class == "カ行変格活用" then
		result = kahen(data, categories)
	elseif data.class == "サ行変格活用" then
		result = sahen(data, categories)
	elseif data.class == "ザ行変格活用" then
		result = zahen(data, categories)
	else
		error("第2引数に有効な活用タイプを指定してください。")
	end

	return result
end

pos_functions["形容詞"] = function(data, categories)
	local gokan
	local gobi
	gokan, gobi = mw.ustring.match(data.term, "^(.*)(い)$")
	if not (gokan and gobi) then
		error("活用タイプと語の形が合っていません。")
	end

	-- 活用テーブル表示用データを組み立てる。
	local stem_form_data = {gokan = gokan, pos = data.pos, gyou = "", class = ""}
	local key_construction_data
	stem_form_data.gobi = {
		kihon = gobi,
		mizen = "かろ",
		renyou = {"く", "かっ"},
		shuushi = "い",
		rentai = "い",
		katei = "けれ",
		meirei = nil
	}
	key_construction_data = {
		{
			imi = "推量・意志",
			gokei = gokan .. "かろう",
			ketsugou = "未然形 + [[う]]"
		},
		{
			imi = "否定形",
			gokei = gokan .. "くない",
			ketsugou = "連用形 + [[ない]]"
		},
		{
			imi = "過去・完了",
			gokei = gokan .. "かった",
			ketsugou = "連用形 + [[た]]"
		},
		{
			imi = "言い切り",
			gokei = gokan .. "い",
			ketsugou = "終止形のみ"
		},
		{
			imi = "名詞化",
			gokei = gokan .. "いこと",
			ketsugou = "連体形 + [[こと]]"
		},
		{
			imi = "仮定条件",
			gokei = gokan .. "ければ",
			ketsugou = "仮定形 + [[ば]]"
		},
		{
			imi = "様態",
			gokei = gokan .. "そうだ",
			ketsugou = "語幹 + [[そうだ]]"
		}
	}

	return create_stem_form_table(stem_form_data) .. '\n' .. create_key_construction_table(key_construction_data)
end

pos_functions["形容動詞"] = function(data, categories)
	local function da(data, categories)
		local gokan = data.term
		local gobi = "だ"

		table.insert(categories, "日本語 形容動詞 ダ活用")

		-- 活用テーブル表示用データを組み立てる。
		local stem_form_data = {gokan = gokan, pos = data.pos, gyou = "", class = "ダ活用"}
		local key_construction_data
		stem_form_data.gobi = {
			kihon = gobi,
			mizen = "だろ",
			renyou = {"だっ", "で", "に"},
			shuushi = "だ",
			rentai = "な",
			katei = "なら",
			meirei = nil
		}
		key_construction_data = {
			{
				imi = "推量・意志",
				gokei = gokan .. "だろう",
				ketsugou = "未然形 + [[う]]"
			},
			{
				imi = "過去・完了",
				gokei = gokan .. "だった",
				ketsugou = "連用形 + [[た]]"
			},
			{
				imi = "否定形",
				gokei = gokan .. "でない",
				ketsugou = "連用形 + [[ない]]"
			},
			{
				imi = "自動詞化",
				gokei = gokan .. "になる",
				ketsugou = "連用形 + [[なる]]"
			},
			{
				imi = "言い切り",
				gokei = gokan .. "だ",
				ketsugou = "終止形のみ"
			},
			{
				imi = "名詞化",
				gokei = gokan .. "なこと",
				ketsugou = "連体形 + [[こと]]"
			},
			{
				imi = "仮定条件",
				gokei = gokan .. "ならば",
				ketsugou = "仮定形 + [[ば]]"
			},
			{
				imi = "様態",
				gokei = gokan .. "そうだ",
				ketsugou = "語幹 + [[そうだ]]"
			}
		}

		return create_stem_form_table(stem_form_data) .. '\n' .. create_key_construction_table(key_construction_data)
	end

	local function taruto(data, categories)
		local gokan = data.term
		local gobi = ""

		table.insert(categories, "日本語 形容動詞 タルト活用")

		-- 活用テーブル表示用データを組み立てる。
		local stem_form_data = {gokan = gokan, pos = data.pos, gyou = "", class = "タルト活用"}
		local key_construction_data
		stem_form_data.gobi = {
			kihon = gobi,
			mizen = nil,
			renyou = "と",
			shuushi = nil,
			rentai = "たる",
			katei = nil,
			meirei = nil
		}
		key_construction_data = {
			{
				imi = "自動詞化",
				gokei = gokan .. "とする",
				ketsugou = "連用形 + [[する]]"
			},
			{
				imi = "名詞化",
				gokei = gokan .. "たること",
				ketsugou = "連体形 + [[こと]]"
			},
		}

		return create_stem_form_table(stem_form_data) .. '\n' .. create_key_construction_table(key_construction_data)
	end

	local result = ""

	if data.class == "ダ活用" then
		result = da(data, categories)
	elseif data.class == "タルト活用" then
		result = taruto(data, categories)
	else
		error("第2引数に有効な活用タイプを指定してください。")
	end

	return result
end

function export.show(frame)
	local DEFAULT_TERM = {
		["動詞"] = {
			["五段活用"] = "あるく",
			["一段活用"] = "たべる",
			["上一段活用"] = "おちる",
			["下一段活用"] = "たべる",
			["カ行変格活用"] = "くる",
			["サ行変格活用"] = "出発",
			["ザ行変格活用"] = "論"
		},
		["形容詞"] = {
			[""] = "あかい",
		},
		["形容動詞"] = {
			["ダ活用"] = "しずか",
			["タルト活用"] = "堂堂"
		}
	}
	local args = frame:getParent().args
	local sort = args["sort"] or ""
	local kana = args["kana"] or args["jsort"] or ""

	local pos = frame.args[1] or error("第1引数に品詞を指定してください。")
	local class = frame.args[2] or ""

	local results = {}
	local categories = {}
	local term

	-- 解説対象の語を決定する。
	local nsText = mw.title.getCurrentTitle().nsText
	if nsText == "テンプレート" then
		term = args[1] or DEFAULT_TERM[pos][class]
	else
		term = args[1] or mw.title.getCurrentTitle().text
	end

	local data = {term = term, pos = pos, class = class, kana = kana}
	if pos_functions[pos] then
		table.insert(categories, "日本語")
		table.insert(categories, "日本語 " .. pos)

		local inflection_table = pos_functions[pos](data, categories)

		table.insert(results, frame:expandTemplate{title = "NavTop", args = {title = "活用と結合例"}})
		table.insert(results, inflection_table)
		table.insert(results, frame:expandTemplate{title = "NavBottom", args = {}})
	else
		error("第1引数に有効な品詞を指定してください。")
	end

	if sort == "" then
		-- ソートキーを自動生成できる場合は生成する。
		if kana ~= "" then
			sort = m_ja.jsort(kana)
		else
			if mw.ustring.find(term, '^[ぁ-ゖァ-ヺー・=]+$') then
				sort = m_ja.jsort(term)
			end
		end
	end

	if sort == term then
		sort = nil
	end

	return table.concat(results, "\n") .. require("Module:utilities").format_categories_using_default_sort(categories, lang, sort)
end

return export