Module:User:Babr

From Wiktionary, the free dictionary
Jump to navigation Jump to search

Lua error in Module:string_utilities at line 959: Module:User:Babr format: "bare_sg" not found in table


local export = {}

local lang = require('Module:languages').getByCode("fa")
local iut = require('Module:inflection utilities')
local m_string_utilities = require("Module:string utilities")
local m_script_utilities = require("Module:script utilities")
local PAGENAME = mw.title.getCurrentTitle().text
local m_params = require("Module:parameters")
local forms = {}

local output_noun_slots = {
	bare_sg = "bare|s",
	bare_pl = "bare|pl",
	bare_brkn = "bare|brkn",
	bare_brkn2 = "bare|brkn2",
	def_sg = "def|s",
	def_pl = "def|p",
	def_brkn = "def|brkn",
	def_brkn2 = "def|brkn2",
	izfh_sg = "izfh|s",
	izfh_pl = "izfh|p",
	izfh_brkn = "izfh|brkn",
	izfh_brkn2 = "izfh|brkn2",
	indef_sg = "indef|s",
	obj_sg = "obj|s",
}

local function decline_noun(decl_spec, lemma)
	local function add(slot, endings)
		iut.insert_form(decl_spec.forms, slot, {form=lemma})
		end
	add("bare_sg", "")
	add("bare_pl", "ها")
	add("bare_brkn", "")
	add("bare_brkn2", "")
	add("def_sg", "")
	add("def_pl", "هارا")
	add("def_brkn", "")
	add("def_brkn2", "")
	add("izfh_sg", "")
	add("izfh_pl", "های")
	add("izfh_brkn", "")
	add("izfh_brkn2", "")
	add("indef_sg", "ای")
	add("obj_sg", "ای‌را")
end

--[==[local function show_forms(decl_spec)
	local lemmas = {}
	if decl_spec.forms.bare_sg then
		for _, bare_sg in ipairs(decl_spec.forms.bare_sg) do
			table.insert(lemmas, bare_sg.form)
		end
	elseif decl_spec.forms.bare_pl then
		for _, bare_pl in ipairs(decl_spec.forms.bare_pl) do
			table.insert(lemmas, bare_pl.form)
		end
	end
	local props = {
		lemmas = lemmas,
		--slot_table = output_noun_slots,
		lang = lang,
		--include_translit = true,
	}
	iut.show_forms(decl_spec.forms, props)
end]==]

local function make_table(decl_spec)

local table_spec_both = [=[
{\op}| class="wikitable vsSwitcher autocollapsed inflection-table" style="text-align:center; border: 0.5px solid #CCC;"
|-
! class="vsToggleElement" style="text-align: center; width:40em" colspan="6" | {title}
|- class="vsHide"
! style="background:#eaecf0" colspan="2" rowspan="2" |
! style="background:#eaecf0;" rowspan="2"| singular
! style="background:#eaecf0;" colspan="3" | plural
|- class="vsHide"
! style="background:#eaecf0; | sound
! style="background:#eaecf0;" colspan="2"| broken
|- class="vsHide"
! style="background:#eaecf0" colspan="2" | bare
| {bare_sg}
| {bare_pl}
| {bare_brkn}
| {bare_brkn2}
|- class="vsHide"
! style="background:#eaecf0" colspan="2" | definite<br>object
| {def_sg}
| {def_pl}
| {def_brkn}
| {def_brkn2}
|- class="vsHide"
! style="background:#eaecf0" colspan="2" | [[Appendix:Persian ezâfe|izofa]]
| {izfh_sg}
| {izfh_pl}
| {izfh_brkn}
| {izfh_brkn2}
|- class="vsHide"
! style="background:#eaecf0" rowspan="2" | indefinite,<br>definite<br>relative
! style="background:#eaecf0" | bare
| {indef_sg}
| —
| —
| —
|- class="vsHide"
! style="background:#eaecf0" | object
| {obj_sg}
| —
| —
| —
|- class="vsHide"
|{\cl}{notes_clause}]=]


forms.title = "forms of" .. PAGENAME

local formatted_table_both = m_string_utilities.format( table_spec_both, forms)

return formatted_table_both
end

function export.do_generate_forms(parent_args, number)
	if number ~= "sg" and number ~= "pl" and number ~= "both" then
		error("Internal error: number (arg 1) must be 'sg', 'pl' or 'both': '" .. number .. "'")
	end

	local params = {
		[1] = {},
		title = {},
	}

	local args = m_params.process(parent_args, params)
	local decl_spec = {
		title = args.title,
		forms = {},
		number = number,
	}
	local lemma = args[1] or PAGENAME
	decline_noun(decl_spec, lemma)
	return decl_spec
end

function export.show(frame)
	local iparams = {
		[1] = {required = true},
	}
	local iargs = m_params.process(frame.args, iparams)
	local parent_args = frame:getParent().args
	local decl_spec = export.do_generate_forms(parent_args, iargs[1])
	--show_forms(decl_spec)
	return make_table(decl_spec_both)
	end

return export