Jump to content

Module:category tree/poscatboiler/data

ពីWiktionary

Documentation for this module may be created at Module:category tree/poscatboiler/data/doc

local labels = {}

local subpages = {
	"entry maintenance",
	"figures of speech",
	"lemmas",
	"miscellaneous",
	"names",
	"non-lemma forms",
	"phrases",
	"rhymes",
	"shortenings",
	"symbols",
	"templates",
	"terms by etymology",
	"terms by lexical property",
	"terms by semantic function",
	"terms by usage",
	"words by number of syllables",
	}

-- 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], "Duplicate 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 and not data.regex then
		for _, parent in ipairs(data.parents) do
			if type(parent) == "table" then
				if parent.name and not parent.template and not parent.name:find("^Category:") then
					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("^Category:") then
					if labels[parent].children then
						table.insert(labels[parent].children, key)
					else
						labels[parent].children = {key}
					end
				end
			end
		end
	end
end

return labels