モジュール:ca-verb
このモジュールについての説明文ページを モジュール:ca-verb/doc に作成できます
--[=[
This module contains functions for creating inflection tables for Catalan
verbs.
Notice:
The bot [[User:MewBot]] uses this module to automatically create entries
for verb forms. If you change how this module works, please notify
the bot owner so the bot can be updated!
]=]--
local m_utilities = require("モジュール:utilities")
local com = require("モジュール:ca-common")
local export = {}
local lang = require("モジュール:languages").getByCode("ca")
-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
local conj_type = frame.args[1] or error("活用の種類が指定されていません。モジュールの呼び出しにパラメータ1を与えて下さい。")
local args = frame:getParent().args
PAGENAME = mw.title.getCurrentTitle().text
NAMESPACE = mw.title.getCurrentTitle().nsText
local forms, title, categories
if conj_type == "ar" then
forms, title, categories = conj_1(args)
elseif conj_type == "re" or conj_type == "er" then
forms, title, categories = conj_2(args)
elseif conj_type == "dre" or conj_type == "ure_ïa" then
forms, title, categories = conj_2_velar(args)
elseif conj_type == "ir_eix" then
forms, title, categories = conj_3(args, true)
elseif conj_type == "ir_no_eix" then
forms, title, categories = conj_3(args, false)
else
error("Unknown conjugation type '" .. conj_type .. "'")
end
if args["bot"] or "" ~= "" then
return make_bot_list(forms, sep ~= "")
else
return make_table(forms, title) .. m_utilities.format_categories(categories, lang)
end
end
-- Conjugate a first conjugation verb (-ar)
function conj_1(args)
local forms = {}
local categories = {"カタルーニャ語 第一変化動詞"}
local title = "[[付録:カタルーニャ語 動詞#第一変化動詞|第一変化]]"
local stems = {}
stems.back = args[1] or (NAMESPACE == "テンプレート" and "-") or error("The first parameter is missing")
make_stems(stems, "a")
forms["infinitive"] = stems.back .. "ar"
forms["pres_part"] = stems.back .. "ant"
forms["past_part"] = stems.back .. "at"
make_pres_1(forms, stems)
make_impf(forms, stems, "a")
make_futr_cond(forms, stems.back .. "a")
make_pret(forms, stems, "a")
make_pres_sub(forms, stems, "a")
make_impf_sub(forms, stems, "a")
-- The verb "donar" gets accents on two of the forms,
-- to distinguish them from the noun "dona".
if stems.back == "don" then
forms["pres_ind_2sg"] = "dónes"
forms["pres_ind_3sg"] = "dóna"
forms["impr_2sg"] = "dóna"
end
return forms, title, categories
end
-- Conjugate a second conjugation verb in -re or unstressed -er
function conj_2(args)
local forms = {}
local categories = {"カタルーニャ語 第二変化動詞"}
local title = "[[付録:カタルーニャ語 動詞#第二変化動詞|第二変化]]"
local stems = {}
stems.front_stressedA = args[1] or (NAMESPACE == "テンプレート" and "-") or error("The first parameter is missing")
stems.front = args[2]; if stems.front == "" then stems.front = nil end
if stems.front then
title = title .. ", 強勢がある時語幹が変化"
table.insert(categories, "カタルーニャ語 語幹が変化する第二変化動詞")
end
make_stems(stems, "e")
if stems.front:find("[cmxs]$") or stems.front:find("ny$") or stems.front:find("rr$") then
forms["infinitive"] = stems.front_stressedA .. "er"
make_futr_cond(forms, stems.front .. "e")
elseif stems.front:find("[ln]$") then
forms["infinitive"] = stems.back_stressed .. "dre"
make_futr_cond(forms, stems.back .. "d")
else
forms["infinitive"] = stems.back_stressed .. "re"
make_futr_cond(forms, stems.back)
end
forms["pres_part"] = stems.front .. "ent"
forms["past_part"] = stems.back .. "ut"
make_pres_23(forms, stems, "e")
make_impf(forms, stems, "e")
make_pret(forms, stems, "e")
make_pres_sub(forms, stems, "e")
make_impf_sub(forms, stems, "e")
local past_part = args["past_part"] or ""
if past_part ~= "" then
forms["past_part"] = past_part
title = title .. ", 不規則過去分詞"
table.insert(categories, "カタルーニャ語 不規則過去分詞の第二変化動詞")
end
return forms, title, categories
end
-- Conjugate a second conjugation verb (-re) with velar infix
function conj_2_velar(args)
local forms = {}
local categories = {"カタルーニャ語 第二変化動詞"}
local title = "[[付録:カタルーニャ語 動詞#Velar-infix stems|second conjugation with velar infix]]"
local stems = {}
stems.front_stressedA = args[1] or (NAMESPACE == "テンプレート" and "-n") or error("The first parameter is missing")
stems.front = args[2]; if stems.front == "" then stems.front = nil end
make_stems(stems, "e")
local velar_stems = {}
velar_stems.back_stressedA = stems.back_stressedA:gsub("v$", "") .. "g"
velar_stems.back = stems.back:gsub("v$", "") .. "g"
make_stems(velar_stems, "e")
if stems.back_stressed:find("[aeiouv]$") then
forms["infinitive"] = stems.back_stressed:gsub("v$", "") .. "ure"
make_futr_cond(forms, stems.back:gsub("v$", "") .. "u")
elseif stems.back_stressed:find("[ln]$") then
forms["infinitive"] = stems.back_stressed .. "dre"
make_futr_cond(forms, stems.back .. "d")
else
error("Invalid stem")
end
forms["pres_part"] = stems.front .. "ent"
forms["past_part"] = velar_stems.back .. "ut"
make_pres_23(forms, stems, "e"); forms["pres_ind_1sg"] = velar_stems.final_stressed
make_impf(forms, stems, "e")
make_pret(forms, velar_stems, "e")
make_pres_sub(forms, velar_stems, "e")
make_impf_sub(forms, velar_stems, "e")
local past_part = args["past_part"] or ""
if past_part ~= "" then
forms["past_part"] = past_part
title = title .. ", 不規則過去分詞"
table.insert(categories, "カタルーニャ語 不規則過去分詞の第二変化動詞")
end
return forms, title, categories
end
-- Conjugate a third conjugation verb (-ir)
function conj_3(args, eix)
local forms = {}
local categories = {"カタルーニャ語 第三変化動詞"}
local title
local stems = {}
stems.front = args[1] or (NAMESPACE == "テンプレート" and "-") or error("The first parameter is missing")
if eix then
table.insert(categories, "カタルーニャ語 -eix-を含む第三変化動詞")
title = "[[付録:カタルーニャ語 動詞#-eix-有り|第三変化動詞(接中辞-eix-有り)]]"
stems.front_stressedA = stems.front .. "eix"
else
table.insert(categories, "カタルーニャ語 -eix-を含まない第三変化動詞")
title = "[[付録:カタルーニャ語 動詞#-eix-無し|第三変化動詞(接中辞-eix-無し)]]"
stems.front_stressedA = args[2]; if stems.front_stressedA == "" then stems.front_stressedA = nil end
if stems.front_stressedA then
title = title .. ", 強勢がある時語幹が変化"
table.insert(categories, "カタルーニャ語 語幹が変化する第三変化動詞")
end
end
make_stems(stems, "i")
forms["infinitive"] = stems.front .. "ir"
forms["pres_part"] = stems.front .. "int"
forms["past_part"] = stems.front_i .. "t"
make_pres_23(forms, stems, "i")
make_impf(forms, stems, "i")
make_futr_cond(forms, stems.front .. "i")
make_pret(forms, stems, "i")
make_pres_sub(forms, stems, "i")
make_impf_sub(forms, stems, "i")
local past_part = args["past_part"] or ""
if past_part ~= "" then
forms["past_part"] = past_part
title = title .. ", 不規則過去分詞"
table.insert(categories, "カタルーニャ語 不規則過去分詞の第三変化動詞")
end
return forms, title, categories
end
-- Create the various base stems that endings are attached to.
function make_stems(stems)
if stems.back or stems.back_stressedA then
stems.back_stressedA = stems.back_stressedA or stems.back
stems.front_stressedA = com.back_to_front(stems.back_stressedA)
stems.back_stressed = com.remove_accents(stems.back_stressedA)
stems.front_stressed = com.remove_accents(stems.front_stressedA)
stems.back = stems.back or stems.back_stressed
stems.front = com.back_to_front(stems.back)
elseif stems.front or stems.front_stressedA then
stems.front_stressedA = stems.front_stressedA or stems.front
stems.back_stressedA = com.front_to_back(stems.front_stressedA)
stems.front_stressed = com.remove_accents(stems.front_stressedA)
stems.back_stressed = com.remove_accents(stems.back_stressedA)
stems.front = stems.front or stems.front_stressed
stems.back = com.front_to_back(stems.front)
else
error("語幹が与えられていません。")
end
-- Does this verb need a diaeresis when endings with -i are attached?
-- Verbs in -aiar, -eiar etc. lose the final -i of the stem
-- when another -i is attached.
local diaeresis = (stems.back:find("[aeiou]$") and not stems.back:find("[aeiou]u$"))
local diaeresis_stressed = (stems.back_stressed:find("[aeiou]$") and not stems.back_stressed:find("[aeiou]u$"))
stems.front_no_i = stems.front:gsub("([aeiou])i$", "%1")
stems.front_stressed_no_i = stems.front_stressed:gsub("([aeiou])i$", "%1")
stems.front_i = stems.front_no_i:gsub("ü$", "u") .. (diaeresis and "ï" or "i")
stems.front_stressed_i = stems.front_stressed_no_i:gsub("ü$", "u") .. (diaeresis_stressed and "ï" or "i")
-- Stems that are used with no following syllable, which have final devoicing.
if stems.back_stressed:find("s$") or stems.back_stressed:find("[ei]n$") then
if stems.back_stressedA:find("[aeiou]") then
stems.final_stressedA = stems.back_stressedA:gsub("ss$", "s")
else
stems.final_stressedA = stems.back_stressed:gsub("ss$", "s")
end
-- l and r can't stand between a consonant and the end or another consonant,
-- so an epenthetic vowel is inserted.
elseif stems.back_stressed:find("[bpdtgc][lr]$") then
stems.final_stressedA = stems.front_stressed .. "e"
elseif stems.back_stressed:find("[aeiou][bd]$") then
stems.final_stressedA = stems.back_stressed:gsub("b$", "p"):gsub("d$", "t")
else
stems.final_stressedA = stems.back_stressed:gsub("g$", "c"):gsub("j$", "ig")
end
stems.final_stressed = com.remove_accents(stems.final_stressedA)
end
function make_pres_1(forms, stems)
forms["pres_ind_1sg"] = stems.back_stressed .. "o"
forms["pres_ind_2sg"] = stems.front_stressed .. "es"
forms["pres_ind_3sg"] = stems.back_stressed .. "a"
forms["pres_ind_1pl"] = stems.front .. "em"
forms["pres_ind_2pl"] = stems.front .. "eu"
forms["pres_ind_3pl"] = stems.front_stressed .. "en"
forms["impr_2sg"] = forms["pres_ind_3sg"]
forms["impr_2pl"] = forms["pres_ind_2pl"]
end
function make_pres_23(forms, stems, vowel)
forms["pres_ind_1sg"] = stems.back_stressed .. "o"
forms["pres_ind_3pl"] = stems.front_stressed .. "en"
-- The 2nd and 3rd person singular present forms have special forms because
-- of the way sounds are combined in them.
forms["pres_ind_2sg"] = stems.final_stressed .. "s"
forms["pres_ind_3sg"] = stems.final_stressedA
-- Verbs ending in a sibilant consonant get an epenthetic vowel
-- in the 2nd person singular.
if stems.front_stressed:find("[cgsx]$") then
forms["pres_ind_2sg"] = stems.front_stressed .. "es"
-- Verbs ending in a vowel add -u in some forms.
elseif stems.back_stressed:find("u$") then
forms["pres_ind_2sg"] = stems.front_stressed .. "us"
forms["pres_ind_3sg"] = stems.front_stressed .. "u"
elseif stems.back_stressed:find("[aeiov]$") then
forms["pres_ind_2sg"] = stems.front_stressed:gsub("v$", "") .. "us"
forms["pres_ind_3sg"] = stems.front_stressed:gsub("v$", "") .. "u"
forms["pres_ind_3pl"] = stems.front_stressed:gsub("v$", "") .. "uen"
end
if vowel == "i" then
forms["pres_ind_1pl"] = stems.front_i .. "m"
forms["pres_ind_2pl"] = stems.front_i .. "u"
else
forms["pres_ind_1pl"] = stems.front .. "em"
forms["pres_ind_2pl"] = stems.front .. "eu"
end
forms["impr_2sg"] = forms["pres_ind_3sg"]
forms["impr_2pl"] = forms["pres_ind_2pl"]
end
function make_impf(forms, stems, vowel)
local stem = stems.back .. "av"
local stemA = stems.back .. "àv"
if vowel ~= "a" then
stem = stems.front_i
stemA = stems.front .. "í"
end
forms["impf_ind_1sg"] = stem .. "a"
forms["impf_ind_2sg"] = stem .. "es"
forms["impf_ind_3sg"] = stem .. "a"
forms["impf_ind_1pl"] = stemA .. "em"
forms["impf_ind_2pl"] = stemA .. "eu"
forms["impf_ind_3pl"] = stem .. "en"
end
function make_pret(forms, stems, vowel)
local stem = stems.back .. "a"
local stemA = stems.back .. "à"
if vowel == "e" then
stem = stems.front .. "e"
stemA = stems.front .. "é"
elseif vowel == "i" then
stem = stems.front_i
stemA = stems.front .. "í"
end
forms["pret_ind_1sg"] = stems.front_no_i .. "í"
forms["pret_ind_2sg"] = stem .. "res"
forms["pret_ind_3sg"] = stemA
forms["pret_ind_1pl"] = stemA .. "rem"
forms["pret_ind_2pl"] = stemA .. "reu"
forms["pret_ind_3pl"] = stem .. "ren"
end
function make_futr_cond(forms, stem)
forms["futr_ind_1sg"] = stem .. "ré"
forms["futr_ind_2sg"] = stem .. "ràs"
forms["futr_ind_3sg"] = stem .. "rà"
forms["futr_ind_1pl"] = stem .. "rem"
forms["futr_ind_2pl"] = stem .. "reu"
forms["futr_ind_3pl"] = stem .. "ran"
forms["cond_1sg"] = stem .. "ria"
forms["cond_2sg"] = stem .. "ries"
forms["cond_3sg"] = stem .. "ria"
forms["cond_1pl"] = stem .. "ríem"
forms["cond_2pl"] = stem .. "ríeu"
forms["cond_3pl"] = stem .. "rien"
end
function make_pres_sub(forms, stems, vowel)
forms["pres_sub_1sg"] = stems.front_stressed_i
forms["pres_sub_2sg"] = stems.front_stressed_i .. "s"
forms["pres_sub_3sg"] = stems.front_stressed_i
if vowel == "i" then
forms["pres_sub_1pl"] = stems.front_i .. "m"
forms["pres_sub_2pl"] = stems.front_i .. "u"
else
forms["pres_sub_1pl"] = stems.front .. "em"
forms["pres_sub_2pl"] = stems.front .. "eu"
end
forms["pres_sub_3pl"] = stems.front_stressed_i .. "n"
forms["impr_3sg"] = forms["pres_sub_3sg"]
forms["impr_1pl"] = forms["pres_sub_1pl"]
forms["impr_3pl"] = forms["pres_sub_3pl"]
end
function make_impf_sub(forms, stems, vowel)
local stem = stems.front .. "e"
local stemA = stems.front .. "é"
if vowel == "i" then
stem = stems.front_i
stemA = stems.front .. "í"
end
forms["impf_sub_1sg"] = stemA .. "s"
forms["impf_sub_2sg"] = stem .. "ssis"
forms["impf_sub_3sg"] = stemA .. "s"
forms["impf_sub_1pl"] = stemA .. "ssim"
forms["impf_sub_2pl"] = stemA .. "ssiu"
forms["impf_sub_3pl"] = stem .. "ssin"
end
-- Make the table
function make_table(forms, title)
-- Make links out of all forms
for key, form in pairs(forms) do
forms[key] = com.link_form(form)
end
return [=[
<div class="NavFrame">
<div class="NavHead" style="text-align: left">'']=] .. forms["infinitive"] .. "''の活用" .. (title and " (" .. title .. ")" or "") .. [=[</div>
<div class="NavContent">
{| style="width:100%;background:#F0F0F0;;padding:.3em"
|-
! colspan="3" style="background:#e2e4c0;" | 不定詞
| colspan="5" style=";"| ]=] .. forms["infinitive"] .. [=[
|-
! colspan="3" style="background:#e2e4c0;" | 現在分詞
| colspan="5" style=";"| ]=] .. forms["pres_part"] .. [=[
|-
! colspan="3" style="background:#e2e4c0;" | 過去分詞
| colspan="5" style=";"| ]=] .. forms["past_part"] .. [=[
|-
! colspan="2" rowspan="2" style="background:#e2e4cb;" | 人称
! colspan="3" style="background:#e2e4cb;" | 単数
! colspan="3" style="background:#e2e4cb;" | 複数
|-
! style="background:#e2e4cb;;width:12.5%" | 一人称
! style="background:#e2e4cb;;width:12.5%" | 二人称
! style="background:#e2e4cb;;width:12.5%" | 三人称
! style="background:#e2e4cb;;width:12.5%" | 一人称
! style="background:#e2e4cb;;width:12.5%" | 二人称
! style="background:#e2e4cb;;width:12.5%" | 三人称
|-
! rowspan="6" style="background:#c0cfe4;" | 直説法
! style="background:#c0cfe4;" |
! style="background:#c0cfe4;" | [[jo]]
! style="background:#c0cfe4;" | [[tu]]
! style="background:#c0cfe4;" | [[ell]]/[[ella]]<br />[[vostè]]
! style="background:#c0cfe4;" | [[nosaltres]]<br />[[nós]]
! style="background:#c0cfe4;" | [[vosaltres]]<br />[[vós]]
! style="background:#c0cfe4;" | [[ells]]/[[elles]]<br />[[vostès]]
|-
! style="height:3em;background:#c0cfe4;" | 現在
| style=";" | ]=] .. forms["pres_ind_1sg"] .. [=[
| style=";" | ]=] .. forms["pres_ind_2sg"] .. [=[
| style=";" | ]=] .. forms["pres_ind_3sg"] .. [=[
| style=";" | ]=] .. forms["pres_ind_1pl"] .. [=[
| style=";" | ]=] .. forms["pres_ind_2pl"] .. [=[
| style=";" | ]=] .. forms["pres_ind_3pl"] .. [=[
|-
! style="height:3em;background:#c0cfe4;" | 不完了過去
| style=";" | ]=] .. forms["impf_ind_1sg"] .. [=[
| style=";" | ]=] .. forms["impf_ind_2sg"] .. [=[
| style=";" | ]=] .. forms["impf_ind_3sg"] .. [=[
| style=";" | ]=] .. forms["impf_ind_1pl"] .. [=[
| style=";" | ]=] .. forms["impf_ind_2pl"] .. [=[
| style=";" | ]=] .. forms["impf_ind_3pl"] .. [=[
|-
! style="height:3em;background:#c0cfe4;" | 未来
| style=";" | ]=] .. forms["futr_ind_1sg"] .. [=[
| style=";" | ]=] .. forms["futr_ind_2sg"] .. [=[
| style=";" | ]=] .. forms["futr_ind_3sg"] .. [=[
| style=";" | ]=] .. forms["futr_ind_1pl"] .. [=[
| style=";" | ]=] .. forms["futr_ind_2pl"] .. [=[
| style=";" | ]=] .. forms["futr_ind_3pl"] .. [=[
|-
! style="height:3em;background:#c0cfe4;" | 完了過去
| style=";" | ]=] .. forms["pret_ind_1sg"] .. [=[
| style=";" | ]=] .. forms["pret_ind_2sg"] .. [=[
| style=";" | ]=] .. forms["pret_ind_3sg"] .. [=[
| style=";" | ]=] .. forms["pret_ind_1pl"] .. [=[
| style=";" | ]=] .. forms["pret_ind_2pl"] .. [=[
| style=";" | ]=] .. forms["pret_ind_3pl"] .. [=[
|-
! style="height:3em;background:#c0cfe4;" | 過去未来・可能法
| style=";" | ]=] .. forms["cond_1sg"] .. [=[
| style=";" | ]=] .. forms["cond_2sg"] .. [=[
| style=";" | ]=] .. forms["cond_3sg"] .. [=[
| style=";" | ]=] .. forms["cond_1pl"] .. [=[
| style=";" | ]=] .. forms["cond_2pl"] .. [=[
| style=";" | ]=] .. forms["cond_3pl"] .. [=[
|-
! style="background:#c0e4c0;" rowspan="3" | 接続法
! style="background:#c0e4c0;" |
! style="background:#c0e4c0;" | jo
! style="background:#c0e4c0;" | tu
! style="background:#c0e4c0;" | ell/ella<br />vostè
! style="background:#c0e4c0;" | nosaltres<br />nós
! style="background:#c0e4c0;" | vosaltres<br />vós
! style="background:#c0e4c0;" | ells/elles<br />vostès
|-
! style="height:3em;background:#c0e4c0;" | 現在
| style=";" | ]=] .. forms["pres_sub_1sg"] .. [=[
| style=";" | ]=] .. forms["pres_sub_2sg"] .. [=[
| style=";" | ]=] .. forms["pres_sub_3sg"] .. [=[
| style=";" | ]=] .. forms["pres_sub_1pl"] .. [=[
| style=";" | ]=] .. forms["pres_sub_2pl"] .. [=[
| style=";" | ]=] .. forms["pres_sub_3pl"] .. [=[
|-
! style="height:3em;background:#c0e4c0;" rowspan="1" | 過去
| style=";" | ]=] .. forms["impf_sub_1sg"] .. [=[
| style=";" | ]=] .. forms["impf_sub_2sg"] .. [=[
| style=";" | ]=] .. forms["impf_sub_3sg"] .. [=[
| style=";" | ]=] .. forms["impf_sub_1pl"] .. [=[
| style=";" | ]=] .. forms["impf_sub_2pl"] .. [=[
| style=";" | ]=] .. forms["impf_sub_3pl"] .. [=[
|-
! colspan="2" rowspan="2" style="height:3em;background:#e4d4c0;" | 命令法
! style="background:#e4d4c0;" | —
! style="background:#e4d4c0;" | tu
! style="background:#e4d4c0;" | vostè
! style="background:#e4d4c0;" | nosaltres
! style="background:#e4d4c0;" | vosaltres<br />vós
! style="background:#e4d4c0;" | vostès
|-
| —
| style=";" | ]=] .. forms["impr_2sg"] .. [=[
| style=";" | ]=] .. forms["impr_3sg"] .. [=[
| style=";" | ]=] .. forms["impr_1pl"] .. [=[
| style=";" | ]=] .. forms["impr_2pl"] .. [=[
| style=";" | ]=] .. forms["impr_3pl"] .. [=[
|}</div></div>]=]
end
-- This generates machine-readable output, which allows formbots to easily
-- parse the output of the module.
function make_bot_list(forms)
local ret = ""
for key, form in pairs(forms) do
ret = ret .. "* " .. key .. "=" .. form .. "\n"
end
return ret
end
return export