Modul:da-adj
Dokumentationen för denna modul kan skapas på Modul:da-adj/dok /test
local gt = require("Modul:grammar-table")
local export = require("Modul:grammar")
local lang_code_param = "da"
local part_of_speech_param = "adj"
local comparative_param = "komp"
local superlative_param = "sup"
local neuter_param = "neutrum"
local positive_param = "pos"
local attributive_param = "attr"
local predicative_param = "pred"
local uncomparable_templatename_suffix = "-okomp"
local periphrastic_templatename_suffix = "-peri"
local inflexible_positive_templatename = "da-adj-0"
function export._getAcceptedParameters()
return {comparative_param, superlative_param, neuter_param, positive_param, attributive_param, predicative_param}
end
function export._getForms(pagename, templatename, args, meta, format)
local common = pagename
local neuter = pagename .. "t"
local plural = pagename .. "e"
local comp = pagename .. "ere"
local sup = pagename .. "est"
local positive_forms_are_not_inflected = meta.positive_uninflected
if positive_forms_are_not_inflected then
common = pagename
neuter = pagename
plural = pagename
end
local forms = {}
forms.attr_obest_sing_utrum_pos = args[1] or common
forms.attr_obest_sing_neutrum_pos = args[2] or neuter
forms.attr_best_sing_pos = args[3] or plural
forms.attr_plur_pos = args[4] or plural
forms.pred_sing_utrum_pos = args[5] or common
forms.pred_sing_neutrum_pos = args[6] or neuter
forms.pred_plur_pos = args[7] or plural
forms.attr_komp = args[8] or comp
forms.pred_komp = args[9] or comp
forms.attr_sup = args[10] or sup
forms.pred_sup = args[11] or sup
if format == "wikitable" or format == "export" then
local no_positive_forms_exist = not meta.pos
local no_suffix_compared_forms_exist = not meta.comp
local no_superlative_forms_exist = not meta.sup
local no_attributive_forms_exist = not meta.attr
local no_predicative_forms_exist = not meta.pred
if no_positive_forms_exist then
forms.attr_obest_sing_utrum_pos = "-"
forms.attr_obest_sing_neutrum_pos = "-"
forms.attr_best_sing_pos = "-"
forms.attr_plur_pos = "-"
forms.pred_sing_utrum_pos = "-"
forms.pred_sing_neutrum_pos = "-"
forms.pred_plur_pos = "-"
end
if no_suffix_compared_forms_exist then
forms.attr_komp = "-"
forms.pred_komp = "-"
end
if no_superlative_forms_exist then
forms.attr_sup = "-"
forms.pred_sup = "-"
end
if no_attributive_forms_exist then
forms.attr_obest_sing_utrum_pos = "-"
forms.attr_obest_sing_neutrum_pos = "-"
forms.attr_best_sing_pos = "-"
forms.attr_plur_pos = "-"
forms.attr_komp = "-"
forms.attr_sup = "-"
end
if no_predicative_forms_exist then
forms.pred_komp = "-"
forms.pred_sup = "-"
end
end
return forms
end
function export._getMeta(pagename, templatename, args)
local positive_forms_are_not_inflected = mw.ustring.sub(templatename, 1, mw.ustring.len(inflexible_positive_templatename)) == inflexible_positive_templatename
local can_not_be_compared = mw.ustring.sub(templatename, -mw.ustring.len(uncomparable_templatename_suffix), -1) == uncomparable_templatename_suffix
local uses_mainly_periphrastic_comparation = mw.ustring.sub(templatename, -mw.ustring.len(periphrastic_templatename_suffix), -1) == periphrastic_templatename_suffix
local uses_suffix_comparation = not (uses_mainly_periphrastic_comparation or can_not_be_compared)
local meta = {}
meta.numbered_cells = 11
meta.named_cells = {}
meta.pos = args[positive_param] ~= "-"
meta.comp = uses_suffix_comparation and args[comparative_param] ~= "-"
meta.sup = uses_suffix_comparation and args[superlative_param] ~= "-"
meta.attr = args[attributive_param] ~= "-"
meta.pred = args[predicative_param] ~= "-"
meta.positive_uninflected = positive_forms_are_not_inflected
meta.suffix_comparison = uses_suffix_comparation
meta.uncomp = can_not_be_compared
meta.peri = uses_mainly_periphrastic_comparation
return meta;
end
function export._getWikitable(forms, meta)
local number_of_columns = meta.suffix_comparison and 5 or 3
local contains_a_quality_notice = not not meta.quality_notice
local uses_suffix_comparation = meta.suffix_comparison
local can_be_used_to_describe_a_person = meta.pers and meta.pers_clear
local uses_second_declension = meta.second_declension
local note = meta.note
local as_first_part = meta.as_first_part
local comparation_text = ""
local is_uncomparable = meta.uncomp
local uses_mainly_periphrastic_comparation = meta.peri
if uses_suffix_comparation then
comparation_text = "Kompareras alternativt med '''mere''' och '''mest'''."
else
if is_uncomparable then
comparation_text = "Kompareras inte."
elseif uses_mainly_periphrastic_comparation then
comparation_text = "Kompareras med '''mere''' och '''mest'''."
end
end
gt.setLanguage(lang_code_param)
local str = gt.getStart(number_of_columns, lang_code_param, part_of_speech_param, contains_a_quality_notice)
if uses_suffix_comparation then
str = str
.. gt.getRow({'!class="main min" rowspan="2" colspan="2"', 'Böjningar av ' .. meta.pagename .. ' ' .. meta.meanings}, {'!', 'Positiv'}, {'!', 'Komparativ'}, {'!', 'Superlativ'})
.. gt.getRow({'!colspan="3"', 'Attributivt'})
.. gt.getRow({'!rowspan="2"', 'Obestämd<br/>singular'}, {'!', 'Utrum'}, forms.attr_obest_sing_utrum_pos, {'|rowspan="4"', forms.attr_komp}, {'!rowspan="2"'})
.. gt.getRow( {'!', 'Neutrum'}, forms.attr_obest_sing_neutrum_pos)
.. gt.getRow({'!colspan="2"', 'Bestämd singular'}, forms.attr_best_sing_pos, {'|rowspan="2"', forms.attr_sup})
.. gt.getRow({'!colspan="2"', 'Plural'}, forms.attr_plur_pos)
.. gt.getRow({'!colspan="2"'}, {'!colspan="3"', 'Predikativt'})
.. gt.getRow({'!rowspan="2"', 'Singular'}, {'!', 'Utrum'}, forms.pred_sing_utrum_pos, {'|rowspan="3"', forms.pred_komp}, {'|rowspan="3"', forms.pred_sup})
.. gt.getRow( {'!', 'Neutrum'}, forms.pred_sing_neutrum_pos)
.. gt.getRow({'!colspan="2"', 'Plural'}, forms.pred_plur_pos)
.. gt.getRow({'!colspan="5"', comparation_text})
else
str = str
.. gt.getRow({'!class="main min" rowspan="2" colspan="2"', 'Böjningar av ' .. meta.pagename .. ' ' .. meta.meanings}, {'!', 'Positiv'})
.. gt.getRow({'!', 'Attributivt'})
.. gt.getRow({'!rowspan="2"', 'Obestämd<br/>singular'}, {'!', 'Utrum'}, forms.attr_obest_sing_utrum_pos)
.. gt.getRow( {'!', 'Neutrum'}, forms.attr_obest_sing_neutrum_pos)
.. gt.getRow({'!colspan="2"', 'Bestämd singular'}, forms.attr_best_sing_pos)
.. gt.getRow({'!colspan="2"', 'Plural'}, forms.attr_plur_pos)
.. gt.getRow({'!colspan="2"'}, {'!', 'Predikativt'})
.. gt.getRow({'!rowspan="2"', 'Singular'}, {'!', 'Utrum'}, forms.pred_sing_utrum_pos)
.. gt.getRow( {'!', 'Neutrum'}, forms.pred_sing_neutrum_pos)
.. gt.getRow({'!colspan="2"', 'Plural'}, forms.pred_plur_pos)
.. gt.getRow({'!colspan="3"', comparation_text})
end
str = str .. gt.getEnd(number_of_columns, note, as_first_part)
return str
end
function export._getCategories(forms, meta)
local str = ""
local neuter_needs_to_but_has_not_been_cleared = not meta.neuter_clear and meta.attr and meta.pos
local undecided_if_adjective_can_describe_a_person = not meta.pers_clear
local undecided_if_adjective_has_an_adverb_derivative = not meta.adv_clear
local has_common_inflection_pattern = not meta.alt_paradigm
local uses_alternative_template = mw.ustring.sub(meta.templatename, 1, mw.ustring.len(alternative_paradigm_templatename)) == alternative_paradigm_templatename
if neuter_needs_to_but_has_not_been_cleared then
str = str .. "[[Kategori:Wiktionary:sv-adj/Saknar neutrum-parameter]]"
end
if undecided_if_adjective_can_describe_a_person then
str = str .. "[[Kategori:Wiktionary:sv-adj/Saknar pers-parameter]]"
end
if undecided_if_adjective_has_an_adverb_derivative then
str = str .. "[[Kategori:Wiktionary:sv-adj/Saknar adv-parameter]]"
end
if has_common_inflection_pattern and uses_alternative_template then
str = str .. "[[Kategori:Wiktionary:sv-adj/Använder fel mall]]"
end
return str
end
return export