Modul:category tree/poscatboiler/data

Vun Wiktionary

This is the main data module for Module:category tree/poscatboiler. It does not contain data itself, but rather imports the data from its submodules, and applies some post-processing.

To add a new data submodule, add its name to the subpages list at the top of the module.


local labels = {}

local subpages = {
--	"entry maintenance",
	"Spraakbiller",
	"Woortaarten",
	"diverse",
	"Naams",
--	"non-lemma forms",
	"Snacks",
--	"rhymes",
--	"shortenings",
	"Symbolen",
	"Vörlagen",
	"Etymologie",
--	"terms by lexical property",
	"Wöör bi semantsche Funktschoon",
--	"terms by usage",
	}
 
-- Import subpages
for _, subpage in ipairs(subpages) do
	local datamodule = "Module:category tree/poscatboiler/data/" .. subpage
	for key, data in pairs(require(datamodule)) do
		assert(not labels[key], "Dubbel label: " .. key)
		data.edit = datamodule
		labels[key] = data
	end
end
 
-- Add child categories to their parents
for key, data in pairs(labels) do
	if data.parents then
		for _, parent in ipairs(data.parents) do
			if type(parent) == "table" then
				if not parent.name:find("^Kategorie:") then
                                        assert(labels[parent.name], "Gin label veur older-name, key: " .. key .." parent.name: " .. parent.name)
					if labels[parent.name].children then
						table.insert(labels[parent.name].children, {name = key, sort = parent.sort})
					else
						labels[parent.name].children = {{name = key, sort = parent.sort}}
					end
				end
			else
				if not parent:find("^Kategorie:") then
					assert(labels[parent], "Gin label veur older, key: " .. key .. " parent: " .. parent)
					if labels[parent].children then
						table.insert(labels[parent].children, key)
					else
						labels[parent].children = {key}
					end
				end
			end
		end
	end
end
 
return labels