Module:User:Benwing2/category tree/poscatboiler/data

Hello, you have come here looking for the meaning of the word Module:User:Benwing2/category tree/poscatboiler/data. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:User:Benwing2/category tree/poscatboiler/data, but we will also tell you about its etymology, its characteristics and you will know how to say Module:User:Benwing2/category tree/poscatboiler/data in singular and plural. Everything you need to know about the word Module:User:Benwing2/category tree/poscatboiler/data you have here. The definition of the word Module:User:Benwing2/category tree/poscatboiler/data will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:User:Benwing2/category tree/poscatboiler/data, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.


local labels = {}
local raw_categories = {}
local handlers = {}
local raw_handlers = {}

local subpages = {
	"characters",
	"entry maintenance",
	"families",
	"figures of speech",
	"lang-specific",
	"languages",
	"lemmas",
	"miscellaneous",
	"names",
	"non-lemma forms",
	"phrases",
	"rhymes",
	"scripts",
	"shortenings",
	"symbols",
	"templates",
	"terms by etymology",
	"terms by grammatical category",
	"terms by lexical property",
	"terms by semantic function",
	"terms by script",
	"terms by usage",
	"transliterations",
	"unicode",
	"word of the day",
	"words by number of syllables",
}

-- Import subpages
for _, subpage in ipairs(subpages) do
	local datamodule
	if subpage == "terms by etymology" or subpage == "names" or subpage == "entry maintenance" or
		subpage == "transliterations" or subpage == "phrases" or subpage == "lang-specific" or
		subpage == "miscellaneous" or subpage == "characters" or subpage == "scripts" or
		subpage == "languages" then
		datamodule = "Module:User:Benwing2/category tree/poscatboiler/data/" .. subpage
	else
		datamodule = "Module:category tree/poscatboiler/data/" .. subpage
	end
	local retval = require(datamodule)
	if retval then
		for label, data in pairs(retval) do
			if labels and not retval then
				error("Label " .. label .. " defined in both [["
					.. datamodule .. "]] and .module .. "]].")
			end
			data.module = datamodule
			labels = data
		end
	end
	if retval then
		for category, data in pairs(retval) do
			if raw_categories and not retval then
				error("Raw category " .. category .. " defined in both [["
					.. datamodule .. "]] and .module .. "]].")
			end
			data.module = datamodule
			raw_categories = data
		end
	end
	if retval then
		for _, handler in ipairs(retval) do
			table.insert(handlers, { module = datamodule, handler = handler })
		end
	end
	if retval then
		for _, handler in ipairs(retval) do
			table.insert(raw_handlers, { module = datamodule, handler = handler })
		end
	end
end

-- Add child categories to their parents
local function add_children_to_parents(hierarchy, raw)
	for key, data in pairs(hierarchy) do
		local parents = data.parents
		if parents then
			if type(parents) ~= "table" then
				parents = {parents}
			end
			if parents.name or parents.module then
				parents = {parents}
			end
			for _, parent in ipairs(parents) do
				if type(parent) ~= "table" or not parent.name and not parent.module then
					parent = {name = parent}
				end
				if parent.name and not parent.module and type(parent.name) == "string" and not parent.name:find("^Category:") then
					local child_is_raw
					if raw then
						child_is_raw = not parent.is_label
					else
						child_is_raw = parent.raw
					end
					local child_hierarchy = child_is_raw and raw_categories or labels
					if child_hierarchy then
						local child = {name = key, sort = parent.sort, raw = raw}
						if child_hierarchy.children then
							table.insert(child_hierarchy.children, child)
						else
							child_hierarchy.children = {child}
						end
					end
				end
			end
		end
	end
end

add_children_to_parents(labels)
add_children_to_parents(raw_categories, true)

return {
	LABELS = labels, RAW_CATEGORIES = raw_categories,
	HANDLERS = handlers, RAW_HANDLERS = raw_handlers
}