Modul:es-adj
Hoppa till navigering
Hoppa till sök
Dokumentation för denna modul finns på /dok (redigera), /test
Syfte[redigera]
Stödja mallarna {{es-adj}}
, {{es-adj-okomp}}
och {{es-adj-oregkomp}}
.
local gt = require("Modul:grammar-table")
local export = require("Modul:grammar")
local lang_code_param = "es"
local part_of_speech_param = "adj"
local uncomparable_templatename_suffix = "-okomp"
function export._getAcceptedParameters()
return {}
end
function export._getForms(pagename, templatename, args, meta, format)
local last_1 = mw.ustring.sub(pagename, -1, -1)
local last_2 = mw.ustring.sub(pagename, -2, -1)
local last_3 = mw.ustring.sub(pagename, -3, -1)
local without_last_1 = mw.ustring.sub(pagename, 1, -2)
local without_last_2 = mw.ustring.sub(pagename, 1, -3)
local without_last_3 = mw.ustring.sub(pagename, 1, -4)
local vowel = "[aeiouáéíóú]"
local consonant = "[bcdfghjklmnñpqrstvwxz]"
local has_irregular_comparation = meta.irreg_comp
local sing_masc = pagename
local sing_fem = "?"
local plur_masc = "?"
local plur_fem = "?"
if last_2 == "oo" then
sing_fem = without_last_2 .. "oa"
plur_masc = without_last_2 .. "oos"
plur_fem = without_last_2 .. "oas"
elseif last_1 == "o" then
sing_fem = without_last_1 .. "a"
plur_masc = without_last_1 .. "os"
plur_fem = without_last_1 .. "as"
elseif last_1 == "a" then
sing_fem = without_last_1 .. "a"
plur_masc = without_last_1 .. "as"
plur_fem = without_last_1 .. "as"
elseif last_1 == "e" then
sing_fem = without_last_1 .. "e"
plur_masc = without_last_1 .. "es"
plur_fem = without_last_1 .. "es"
elseif last_3 == "ior" then
sing_fem = without_last_3 .. "ior"
plur_masc = without_last_3 .. "iores"
plur_fem = without_last_3 .. "iores"
elseif last_2 == "or" then
sing_fem = without_last_2 .. "ora"
plur_masc = without_last_2 .. "ores"
plur_fem = without_last_2 .. "oras"
elseif last_2 == "án" then
sing_fem = without_last_2 .. "ana"
plur_masc = without_last_2 .. "anes"
plur_fem = without_last_2 .. "anas"
elseif last_2 == "ón" then
sing_fem = without_last_2 .. "ona"
plur_masc = without_last_2 .. "ones"
plur_fem = without_last_2 .. "onas"
elseif last_2 == "ún" then
sing_fem = without_last_2 .. "una"
plur_masc = without_last_2 .. "unes"
plur_fem = without_last_2 .. "unas"
elseif last_2 == "ín" then
sing_fem = without_last_2 .. "ina"
plur_masc = without_last_2 .. "ines"
plur_fem = without_last_2 .. "inas"
elseif last_2 == "és" then
sing_fem = without_last_2 .. "esa"
plur_masc = without_last_2 .. "eses"
plur_fem = without_last_2 .. "esas"
elseif last_1 == "í" then
sing_fem = without_last_1 .. "í"
plur_masc = without_last_1 .. "íes, (" .. without_last_1 .. "ís)"
plur_fem = without_last_1 .. "íes, (" .. without_last_1 .. "ís)"
elseif last_3 == "sis" then
sing_fem = without_last_3 .. "sis"
plur_masc = without_last_3 .. "sis"
plur_fem = without_last_3 .. "sis"
elseif last_3 == "sus" then
sing_fem = without_last_3 .. "sus"
plur_masc = without_last_3 .. "sus"
plur_fem = without_last_3 .. "sus"
elseif last_1 == "z" then
sing_fem = without_last_1 .. "z"
plur_masc = without_last_1 .. "ces"
plur_fem = without_last_1 .. "ces"
elseif mw.ustring.find(last_1, consonant) then
sing_fem = without_last_1 .. last_1
plur_masc = without_last_1 .. last_1 .. "es"
plur_fem = without_last_1 .. last_1 .. "es"
elseif mw.ustring.find(last_1, vowel) then
sing_fem = without_last_1 .. last_1
plur_masc = without_last_1 .. last_1 .. "s"
plur_fem = without_last_1 .. last_1 .. "s"
end
local forms = {}
forms.sing_mask = args[1] or sing_masc
forms.sing_fem = args[2] or sing_fem
forms.plur_mask = args[3] or plur_masc
forms.plur_fem = args[4] or plur_fem
if has_irregular_comparation then
forms.sing_mask_komp = args[5] or "?"
forms.sing_fem_komp = args[6] or "?"
forms.plur_mask_komp = args[7] or "?"
forms.plur_fem_komp = args[8] or "?"
forms.sing_mask_sup = args[9] or "?"
forms.sing_fem_sup = args[10] or "?"
forms.plur_mask_sup = args[11] or "?"
forms.plur_fem_sup = args[12] or "?"
end
return forms
end
function export._getMeta(pagename, templatename, args)
local can_not_be_compared = mw.ustring.sub(templatename, -mw.ustring.len(uncomparable_templatename_suffix), -1) == uncomparable_templatename_suffix
local has_irregular_comparation = not can_not_be_compared and args[5] or args[6] or args[7] or args[8] or args[9] or args[10] or args[11] or args[12]
local meta = {}
meta.numbered_cells = has_irregular_comparation and 12 or 4
meta.named_cells = {}
meta.uncomp = can_not_be_compared
meta.irreg_comp = has_irregular_comparation
return meta
end
function export._getWikitable(forms, meta)
local contains_a_quality_notice = not not meta.quality_notice
local note = meta.note
local as_first_part = meta.as_first_part
local comparation_text = ""
local is_uncomparable = meta.uncomp
local has_regular_comparation = not meta.irreg_comp
local number_of_columns = has_regular_comparation and 3 or 5
gt.setLanguage(lang_code_param)
if has_regular_comparation and is_uncomparable then
comparation_text = "Kompareras inte."
else
comparation_text = "Kompareras med '''más''' och '''el/la/lo/los/las más'''."
end
local sing_forms_are_identical = forms.sing_mask == forms.sing_fem
local plur_forms_are_identical = forms.plur_mask == forms.plur_fem
local sing_mask_cell = sing_forms_are_identical and {'|rowspan="2"', forms.sing_mask} or forms.sing_mask
local sing_fem_cell = not sing_forms_are_identical and forms.sing_fem
local plur_mask_cell = plur_forms_are_identical and {'|rowspan="2"', forms.plur_mask} or forms.plur_mask
local plur_fem_cell = not plur_forms_are_identical and forms.plur_fem
local sing_komp_forms_are_identical = forms.sing_mask_komp == forms.sing_fem_komp
local plur_komp_forms_are_identical = forms.plur_mask_komp == forms.plur_fem_komp
local sing_mask_komp_cell = sing_komp_forms_are_identical and {'|rowspan="2"', forms.sing_mask_komp} or forms.sing_mask_komp
local sing_fem_komp_cell = not sing_komp_forms_are_identical and forms.sing_fem_komp
local plur_mask_komp_cell = plur_komp_forms_are_identical and {'|rowspan="2"', forms.plur_mask_komp} or forms.plur_mask_komp
local plur_fem_komp_cell = not plur_komp_forms_are_identical and forms.plur_fem_komp
local sing_sup_forms_are_identical = forms.sing_mask_sup == forms.sing_fem_sup
local plur_sup_forms_are_identical = forms.plur_mask_sup == forms.plur_fem_sup
local sing_mask_sup_cell = sing_sup_forms_are_identical and {'|rowspan="2"', forms.sing_mask_sup} or forms.sing_mask_sup
local sing_fem_sup_cell = not sing_sup_forms_are_identical and forms.sing_fem_sup
local plur_mask_sup_cell = plur_sup_forms_are_identical and {'|rowspan="2"', forms.plur_mask_sup} or forms.plur_mask_sup
local plur_fem_sup_cell = not plur_sup_forms_are_identical and forms.plur_fem_sup
local str = ""
if has_regular_comparation then
str = str
.. gt.getStart(number_of_columns, lang_code_param, part_of_speech_param, contains_a_quality_notice)
.. gt.getRow({'!class="main min"', 'Böjningar av ' .. meta.pagename .. ' ' .. meta.meanings}, {'!', 'Singular'}, {'!', 'Plural'})
.. gt.getRow({'!', 'Maskulinum'}, sing_mask_cell, plur_mask_cell)
.. gt.getRow({'!', 'Femininum'}, sing_fem_cell, plur_fem_cell)
.. gt.getRow({'!colspan="3"', comparation_text})
.. gt.getEnd(number_of_columns, note, as_first_part)
else
str = str
.. gt.getStart(number_of_columns, lang_code_param, part_of_speech_param, contains_a_quality_notice)
.. gt.getRow({'!class="main min" colspan="2"', 'Böjningar av ' .. meta.pagename .. ' ' .. meta.meanings}, {'!', 'Positiv'}, {'!', 'Komparativ'}, {'!', 'Superlativ'})
.. gt.getRow({'!rowspan="2"', 'Singular'}, {'!', 'Maskulinum'}, sing_mask_cell, sing_mask_komp_cell, sing_mask_sup_cell)
.. gt.getRow( {'!', 'Femininum'}, sing_fem_cell, sing_fem_komp_cell, sing_fem_sup_cell)
.. gt.getRow({'!rowspan="2"', 'Plural'}, {'!', 'Maskulinum'}, plur_mask_cell, plur_mask_komp_cell, plur_mask_sup_cell)
.. gt.getRow( {'!', 'Femininum'}, plur_fem_cell, plur_fem_komp_cell, plur_fem_sup_cell)
.. gt.getEnd(number_of_columns, note, as_first_part)
end
return str
end
function export._getCategories(forms, meta)
local one_or_more_forms_are_missing = forms.plur_masc == "?" or forms.sing_fem == "?" or forms.plur_fem == "?"
local str = ""
if one_or_more_forms_are_missing then
str = str .. "[[Kategori:Wiktionary:es-adj/Former saknas]]"
end
return str
end
return export