モジュール:eu-headword

出典: フリー多機能辞典『ウィクショナリー日本語版(Wiktionary)』
ナビゲーションに移動 検索に移動

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

local export = {}
local lang = require("モジュール:languages").getByCode("eu")

--adverbs
function export.show_adv(frame)
	local args = frame:getParent().args
	local data = {lang = lang, pos_category = "副詞", categories = {}, sort_key = args.sort, heads = {args.head}, genders = {}, inflections = {}}
	local tracking_categories = {}
	local stem = mw.title.getCurrentTitle().text
	local comparative, superlative, excessive = {}, {}, {}
	if	stem:sub(-1) == "r" then
		 stem = stem .. 'r' --add an r if the adjective ends in r
	elseif stem:sub(-1) == "a" then
		 stem = stem:sub(1, -2)
	end
	if args[1] == "-" then
		table.insert(data.categories, "バスク語 副詞 比較形無し")
		data.inflections = {{label = "比較形無し"}}
	else
		data.inflections = {{label = "比較級", accel = {form = "comparative"}, stem .. "ago"}, {label = "最上級", accel = {form = "superlative"}, stem .. "en"}, 
			{label = "excessive", accel = {form = "excd"}, stem .. "egi"}}
	end
	return require("モジュール:headword").full_headword(data) ..
		require("モジュール:utilities").format_categories(tracking_categories, lang, args.sort)
end


--adjectives
function export.show_adj(frame)
	local args = frame:getParent().args
	local data = {lang = lang, pos_category = "形容詞", categories = {}, sort_key = args.sort, heads = {args.head}, genders = {}, inflections = {}}
	local tracking_categories = {}
	local stem = mw.title.getCurrentTitle().text
	local comparative, superlative, excessive = {}, {}, {}
	if	stem:sub(-1) == "r" then
		 stem = stem .. 'r' --add an r if the adjective ends in r
	elseif stem:sub(-1) == "a" then
		 stem = stem:sub(1, -2)
	end
	if args[1] == "-" then
		table.insert(data.categories, "バスク語 形容詞 比較形無し")
		data.inflections = {{label = "比較形無し"}}
	else
		data.inflections = {{label = "比較級", accel = {form = "comparative"}, stem .. "ago"}, {label = "最上級", accel = {form = "superlative"}, stem .. "en"}, 
			{label = "excessive", accel = {form = "excd"}, stem .. "egi"}}
	end
	return require("モジュール:headword").full_headword(data) ..
		require("モジュール:utilities").format_categories(tracking_categories, lang, args.sort)
end

--nouns
function export.show_noun(frame)
	local args = frame:getParent().args
	local data = {lang = lang, pos_category = frame.args.proper and "固有名詞" or "名詞", categories = {}, sort_key = args.sort, heads = {args.head}, genders, inflections = {}}
	local tracking_categories = {}

	local g, genders = args.g or args[1]
	if g == "an" then
		data.genders = { "an" }
	elseif g == "in" then
		data.genders = { "in" }
	elseif g == "both" then
		data.genders = { "in","an" }
	else
		data.genders = { "?" }
	end

	return require("モジュール:headword").full_headword(data) ..
		require("モジュール:utilities").format_categories(tracking_categories, lang, args.sort)
end


--verbs
function export.show_verb(frame)
	local args = frame:getParent().args
	local data = {lang = lang, pos_category = "動詞", categories = {}, sort_key = args.sort, heads = {args.head}, genders = {}, inflections = {}}
	local tracking_categories = {}
	local stem = mw.title.getCurrentTitle().text
	local stem_s = stem
	local ending = ""
	
	if	stem:sub(-2,-1) == "tu" then
		 stem_s = stem:sub(1, -3)
		 ending = "tu"
	elseif stem:sub(-2,-1) == "du" then
		stem_s = stem:sub(1, -3)
		ending = "du"
	elseif stem:sub(-1) == "n" then
		stem_s = stem:sub(1,-2)
		ending = "n"
	elseif stem:sub(-1) == "i" then
		stem_s = stem:sub(1,-2)
		ending = "i"
	end
	
	--some verbs ending in -i can have "irregular" short forms (they are predictable, but as there aren't many of them it's easier to enter them manually)
	if args.inf or args.short or args[1] then
		stem_s = args.inf or args.short or args[1]
	end
	
	--for verbs ending in -rri
	if stem_s:sub(-2,-1) == "rr" then
		stem_s = stem_s:sub(1,-2)
	end
	
	--generate the non-finite forms
	if ending == "du" or ending == "tu" then
		fut_part = stem .. "ko"
		inf = stem_s
		if  ('szx'):match(stem_s:sub(-1)) then
			v_noun = stem_s .. "te"
		else
			v_noun = stem_s .. "tze"
		end
	elseif ending == "n" then
		fut_part = stem .. "go"
		inf = stem
		v_noun = stem_s .. "te"
	elseif ending == "i" then
		fut_part = stem .. "ko"
		inf = stem_s
		if stem_s:sub(-2,-1) == "tz" then
			v_noun = stem_s:sub(1,-3) .. "zte"
		elseif stem_s:sub(-2,-1) == "ts" then
			v_noun = stem_s:sub(1,-3) .. "ste"
		elseif stem_s:sub(-2,-1) == "tx" then
			v_noun = stem_s:sub(1,-3) .. "xte"
		elseif  ('szx'):match(stem_s:sub(-1)) then
			v_noun = stem_s .. "te"
		else
			v_noun = stem_s .. "tze"
		end
	else
		fut_part = stem .. "ko"
		inf = stem
		v_noun = stem_s .. "tze"
	end

	--for verbs like "ezagutu", where the short form isn't "ezagu", but "ezagut"
	if args[2] then
		inf = args[2]
	end
	
	data.inflections = {{label = "現在分詞", v_noun .. "n"}, {label = "未来分詞", fut_part}, {label = "不定詞", inf}, {label = "動名詞", v_noun}}

	return require("モジュール:headword").full_headword(data) ..
		require("モジュール:utilities").format_categories(tracking_categories, lang, args.sort)
end

return export