Module:auto cat/data

-------------------------
--[[  AUTO CAT DATA  ]]--
-------------------------
-- %l = any language name
-- %u = any language name (different to %l)
-- %c = any language code
-- %p = any part of speech
-- %ps = any part of speech (plural)
-- %s = any string
-------------------------
-- Please note that the order of patterns
-- makes a difference
-- Patterns higher up in the table will be
-- matched against first.
-------------------------
local subtopics = {
	-- ["this is a subtopic of"] = "just this", 
	-- ["this is a subtopic of"] = {"this", "this too"}, 
	
	["organs"] = {"anatomy"},
	
	["birds"] = {"animals"},
	["insects"] = {"animals"},
	
	["biochemistry"] = {"biology","chemistry"},
		["enzymes"] = "biochemistry",
	
	["inorganic chemistry"] = "chemistry",
	["organic chemistry"] = "chemistry",
	["sugars"] = "chemistry",
	
	["botany"] = "biology",
	["cytology"] = "biology",
	["genetics"] = "biology",
	["microbiology"] = "biology",
	["molecular biology"] = "biology",
	["physiology"] = "biology",
	["taxonomy"] = "biology",
	["virology"] = "biology",
	["zoology"] = "biology",
	
	["phonetics"] = "linguistics",
	["phonology"] = "linguistics",
	
	["algebra"] = "mathematics",
	["arithmetic"] = "mathematics",
	["calculus"] = "mathematics",
	["geometry"] = "mathematics",
	["statistics"] = "mathematics",
	["trigonometry"] = "mathematics",
		["trigonometric functions"] = "trigonometry",
	
	["pharmacology"] = "medicine",
	["psychiatry"] = "medicine",
	
	["nuclear physics"] = "physics",
	
	["taxa"] = "taxonomy",
	
	["months"] = "time",
	["seasons"] = "time",
	["days"] = "time",
}

local pos = {
    "adjective",
    "adverb",
	"article",
    "conjunction",
    "determiner",
    "interjection",
	"noun",
    "numeral",
    "particle",
    "participle",
    "phrase",
    "postposition",
    "preposition",
    "pronoun",
    "proper noun",
    "symbol",
    "verb",
}

local cats = {
    {"Fundamental", {"Fundamental| "}},
    
    -- General maintenance
    {"Pages with script errors", {"Fundamental| "}},
    {"Pages marked as works in progress", {"Fundamental| "}},
    {"Obsolete", {"Fundamental| "}},
    	{"Label templates", {"Obsolete| "}},
    	{"%s entries", {"Obsolete| "}},
    
    -- Languages
    {"All languages", {"Fundamental| "}},
    	{"%l language", {"All languages"}},
    		{"%l images", {"%l language| "}},
    -- Encyclopedia
    {"Encyclopedia articles by language", {"Fundamental"}},
    	{"%l encyclopedia articles", {"%l language| ", "Encyclopedia articles by language"}},
    {"Phrasebooks", {"Fundamental"}},
    -- Appendices
    {"Appendices", {"Fundamental| "}},
	    {"Appendices by language", {"Appendices| "}},
	    	{"%l appendices", {"Appendices by language"}},
    -- Lexember
    {"Lexember", {"Fundamental"}},
	    {"Lexember 2023", {"Lexember|2023"}},
	    		{"Lexember 2023 Day %s: %l", {"Lexember 2023: %l| ", "Lexember 2023 Day %s|%l"}},
	    	{"Lexember 2023 Day %s", {"Lexember 2023| "}},
		    {"Lexember 2023: %l", {"%l language|Lexember 2023", "Lexember 2023|%l"}},
    -- Rhymes
    {"Rhymes", {"Fundamental"}},
    	{"Rhymes:%l", {"%l language| ", "Rhymes|%l"}},
    		{"%l active rhymes", {"%l language| ", "Rhymes:%l| "}},
    		{"Rhymes:%l/%s", {"Rhymes:%l|%s", {text = "%l active rhymes|%s", condition = function(category_name) return mw.site.stats.pagesInCategory(category_name, "pages") > 1 end}}},
    -- Lemmas by language
    {"Lemmas by language", {"Fundamental| "}},
    	{"Lemmas subcategories by language", {"Lemmas by language| "}},
    		{"Multiword terms by language", {"Lemmas subcategories by language"}},
    			{"%l multiword terms", {"%l language| ", "Multiword terms by language"}},
			{"Terms with multiple pronunciations by language", {"Lemmas subcategories by language"}},
    			{"%l terms with multiple pronunciations", {"%l language| ", "Terms with multiple pronunciations by language"}},
			{"Terms with dialect pronunciations by language", {"Lemmas subcategories by language"}},
    			{"%l terms with %s dialect pronunciation", {"%l language| ", "Terms with dialect pronunciations by language", "Terms with dialect pronunciations by language"}},
    	{"%ps by language", {"Lemmas by language| "}},
    	{"%l lemmas", {"%l language| ", "Lemmas by language"}},
    		{"%l %ps", {"%l lemmas|%ps", "%ps by language"}},

    -- Non-lemmas by language
    {"Non-lemma forms by language", {"Fundamental| "}},
    	{"Non-lemma forms subcategories by language", {"Non-lemma forms by language| "}},
    		{"%p forms by language", {"Non-lemma forms subcategories by language"}},
    		{"Suffix forms by language", {"Non-lemma forms subcategories by language"}},
    	{"%l non-lemma forms", {"%l language| ", "Non-lemma forms by language"}},
    		{"%l %p forms", {"%l non-lemma forms|%p forms", "%l %ps| ", "%p forms by language"}},
    			{"%l %s %p forms", {"%l %p forms|%s"}},
    			{"%l suffix forms", {"%l non-lemma forms|suffix forms", "%l suffixes| ", "Suffix forms by language"}},
    		{"%l verbal nouns", {"%l non-lemma forms|verbal nouns", "%l nouns| ", "Verbal nouns by language"}},
    		{"Verbal nouns by language", {"Non-lemma forms subcategories by language"}},
    
    
    -- Morphemes by language
    {"Morphemes by language", {"Lemmas by language"}},
    {"Affixes by language", {"Morphemes by language"}},
    {"Prefixes by language", {"Affixes by language| "}},
    {"Suffixes by language", {"Affixes by language| "}},
    {"Infixes by language", {"Affixes by language| "}},
    {"Circumfixes by language", {"Affixes by language| "}},
    {"Clitics by language", {"Morphemes by language"}},
    -- Language morphemes
    {"%l morphemes", {"%l lemmas", "Morphemes by language"}},
    {"%l affixes", {"%l morphemes", "%l lemmas", "Affixes by language"}},
    {"%l prefixes", {"%l morphemes", "%l affixes", "Prefixes by language"}},
    	{"%l %s prefixes", {"%l prefixes"}},
    {"%l suffixes", {"%l morphemes", "%l affixes", "Suffixes by language"}},
    	{"Nominal suffixes by language", {"Lemmas subcategories by language"}},
    	{"Verbal suffixes by language", {"Lemmas subcategories by language"}},
    	{"Adjectival suffixes by language", {"Lemmas subcategories by language"}},
    	{"%l nominal suffixes", {"%l suffixes", "Nominal suffixes by language"}},
		{"%l adjectival suffixes", {"%l suffixes", "Adjectival suffixes by language"}},
    	{"%l verbal suffixes", {"%l suffixes", "Verbal suffixes by language"}},
    	{"%l %s suffixes", {"%l suffixes"}},
    {"%l infixes", {"%l morphemes", "%l affixes", "Infixes by language"}},
    	{"%l %s infixes", {"%l infixes"}},
    {"%l circumfixes", {"%l morphemes", "%l affixes", "Circumfixes by language"}},
    {"%l clitics", {"%l morphemes", "Clitics by language"}},
    -- Types of lemma by language
    {"%s %ps by language", {"Lemmas subcategories by language"}},
    {"%ps with multiple genders by language", {"Lemmas subcategories by language"}},
    {"%ps with multiple animacies by language", {"Lemmas subcategories by language"}},
    
    -- Language types of lemma *with cross-linguistic category*
    {"%s %ps by language", {"Lemmas subcategories by language"}},
	    {"%l comparable %ps", {"%l %ps| ", "Comparable %ps by language"}},
	    {"%l uncomparable %ps", {"%l %ps| ", "Uncomparable %ps by language"}},
		{"%l spatial prepositions", {"%l prepositions| ", "Spatial prepositions by language"}},
		{"%l temporal prepositions", {"%l prepositions| ", "Temporal prepositions by language"}},
	    {"%l possessive pronouns", {"%l pronouns| ", "Possessive pronouns by language"}},
	    {"%l relative pronouns", {"%l pronouns| ", "Relative pronouns by language"}},
	    {"%l imperfective verbs", {"%l verbs| ", "Imperfective verbs by language"}},
	    {"%l perfective verbs", {"%l verbs| ", "Perfective verbs by language"}},
	    {"%l biaspectual verbs", {"%l verbs| ", "Biaspectual verbs by language"}},
	    {"%l transitive verbs", {"%l verbs| ", "Transitive verbs by language"}},
	    {"%l intransitive verbs", {"%l verbs| ", "Intransitive verbs by language"}},
	    {"%l auxiliary verbs", {"%l verbs| ", "Auxiliary verbs by language"}},
	    {"%l copulative verbs", {"%l verbs| ", "Copulative verbs by language"}},
	    {"%l deponent verbs", {"%l verbs| ", "Deponent verbs by language"}},
	    {"%l ditransitive verbs", {"%l verbs| ", "Ditransitive verbs by language"}},
	    {"%l impersonal verbs", {"%l verbs| ", "Impersonal verbs by language"}},
	    {"%l stative verbs", {"%l verbs| ", "Stative verbs by language"}},
	    {"%l passive verbs", {"%l verbs| ", "Passive verbs by language"}},
	    {"%l reflexive verbs", {"%l verbs| ", "Reflexive verbs by language"}},
	    {"%l mediopassive verbs", {"%l verbs| ", "Mediopassive verbs by language"}},
	    {"%l neuter %ps", {"%l %ps| ", "Neuter %ps by language"}},
	    {"%l feminine %ps", {"%l %ps| ", "Feminine %ps by language"}},
	    {"%l masculine %ps", {"%l %ps| ", "Masculine %ps by language"}},
	    {"%l common %ps", {"%l %ps| ", "Common %ps by language"}},
	    {"%l inanimate %ps", {"%l %ps| ", "Inanimate %ps by language"}},
	    {"%l animate %ps", {"%l %ps| ", "Animate %ps by language"}},
	    {"%l personal %ps", {"%l %ps| ", "Personal %ps by language"}},
	    {"%l nonpersonal %ps", {"%l %ps| ", "Nonpersonal %ps by language"}},
	    {"%l animal %ps", {"%l %ps| ", "Animal %ps by language"}},
	    {"%l nonvirile %ps", {"%l %ps| ", "Nonvirile %ps by language"}},
	    {"%l virile %ps", {"%l %ps| ", "Virile %ps by language"}},
		   
	{"Singularia tantum by language", {"Lemmas subcategories by language"}},
	    {"%l singularia tantum", {"%l nouns| ", "Singularia tantum by language"}},
	{"Dualia tantum by language", {"Lemmas subcategories by language"}},
	    {"%l dualia tantum", {"%l nouns| ", "Dualia tantum by language"}},
	{"Pluralia tantum by language", {"Lemmas subcategories by language"}},
	    {"%l pluralia tantum", {"%l nouns| ", "Pluralia tantum by language"}},
    {"%ps with multiple genders by language", {"Lemmas subcategories by language"}},
	    {"%l %ps with multiple genders", {"%l %ps| ", "%ps with multiple genders by language"}},
    {"%ps with multiple animacies by language", {"Lemmas subcategories by language"}},
	    {"%l %ps with multiple animacies", {"%l %ps| ", "%ps with multiple animacies by language"}},
 
	    -- Radestrian-specific non-automatic PoS subcategories
	    {"Radestrian pluralia binaria", {"Radestrian nouns"}},
	    	{"Radestrian pluralia binaria tantum", {"Radestrian nouns", "Radestrian pluralia binaria| "}},
    
    {"%l %s %ps", {"%l %ps| "}}, -- sorts all other PoS descriptors under the PoS but not under a cross-linguistic category (e.g. Virile nouns by language). More for language-specific PoS subcategories.
    
    -- Stems
    	{"%l terms by stem type", {"%l language| "}},
	    	{"%l %s stems", {"%l terms by stem type"}},
    
    -- Government
    {"Lemmas government by language", {"Lemmas subcategories by language| "}},
	    {"%ps governing the %s by language", {"Lemmas government by language| "}},
	    {"%l lemmas government", {"%l lemmas| ", "Lemmas government by language"}},
	    	{"%l %ps governing the %s", {"%l %ps| ", "%l lemmas government| ", "%ps governing the %s by language"}},
    
    -- Roots by language
    {"Root-derived terms by language", {"Fundamental| "}},
    	{"Terms derived from %l roots", {"%l roots", "Terms derived from %l| ", "Root-derived terms by language"}},
    		{"Terms derived from the %l root %s", {"Terms derived from %l roots"}},
    {"Terms by root by language", {"Terms by etymology subcategories by language"}},
    {"Roots by language", {"Terms by etymology subcategories by language"}},
    	{"Nominal roots by language", {"Roots by language| "}},
    	{"Numeral roots by language", {"Roots by language| "}},
    	{"Verbal roots by language", {"Roots by language| "}},
    	{"Adjectival roots by language", {"Roots by language| "}},
    	{"Grammatical roots by language", {"Roots by language| "}},
    {"Terms by %l root by language", {"Terms by etymology subcategories by language|%l"}},
    -- Language roots
    {"%l roots", {"%l language| ", "%l morphemes", "Roots by language"}},
		{"%l nominal roots", {"%l roots", "Nominal roots by language"}},
		{"%l numeral roots", {"%l roots", "Numeral roots by language"}},
		{"%l verbal roots", {"%l roots", "Verbal roots by language"}},
		{"%l adjectival roots", {"%l roots", "Adjectival roots by language"}},
		{"%l grammatical roots", {"%l roots", "Grammatical roots by language"}},
		{"%l terms by root", {"%l terms by etymology", "%l roots", "Terms by root by language"}},
    		{"%l terms belonging to the root %s", {"%l terms by root|%s"}},
    		{"%l terms by %u root", {"%l terms by etymology", "%l terms derived from %u", "Terms by %u root by language"}},
    {"%l terms derived from the %u root %s", {"%l terms by %u root", "Terms derived from the %u root %s"}},
    -- Etymology by language
    {"Terms by etymology by language", {"Fundamental| "}},
	    {"Terms by etymology subcategories by language", {"Terms by etymology by language| "}},
	    	-- Language etymology (no source)
		    {"Abbreviations by language", {"Terms by etymology subcategories by language"}},
		    	{"%l abbreviations", {"%l terms by etymology", "Abbreviations by language"}},
		    {"Acronyms by language", {"Terms by etymology subcategories by language"}},
		    	{"%l acronyms", {"%l terms by etymology", "Acronyms by language"}},
		    {"Adjectivisations by language", {"Terms by etymology subcategories by language"}},
    			{"%l adjectivisations", {"%l terms by etymology", "Adjectivisations by language"}},
		    {"Back-formations by language", {"Terms by etymology subcategories by language"}},
		    	{"%l back-formations", {"%l terms by etymology", "Back-formations by language"}},
		    {"Blends by language", {"Terms by etymology subcategories by language"}},
		    	{"%l blends", {"%l terms by etymology", "Blends by language"}},
		    {"Clippings by language", {"Terms by etymology subcategories by language"}},
		    	{"%l clippings", {"%l terms by etymology", "Clippings by language"}},
		    {"Contractions by language", {"Terms by etymology subcategories by language"}},
		    	{"%l contractions", {"%l terms by etymology", "Contractions by language"}},
		    {"Deadjectivals by language", {"Terms by etymology subcategories by language"}},
		    	{"%l deadjectivals", {"%l terms by etymology", "Deadjectivals by language"}},
		    {"Denominals by language", {"Terms by etymology subcategories by language"}},
		    	{"%l denominals", {"%l terms by etymology", "Denominals by language"}},
		    {"Deverbals by language", {"Terms by etymology subcategories by language"}},
		    	{"%l deverbals", {"%l terms by etymology", "Deverbals by language"}},
		    {"Doublets by language", {"Terms by etymology subcategories by language"}},
		    	{"%l doublets", {"%l terms by etymology", "Doublets by language"}},
		    {"Ellipses by language", {"Terms by etymology subcategories by language"}},
		    	{"%l ellipses", {"%l terms by etymology", "Ellipses by language"}},
		    {"Initialisms by language", {"Terms by etymology subcategories by language"}},
		    	{"%l initialisms", {"%l terms by etymology", "Initialisms by language"}},
		    {"Nominalisations by language", {"Terms by etymology subcategories by language"}},
		    	{"%l nominalisations", {"%l terms by etymology", "Nominalisations by language"}},
		    {"Onomatopoeias by language", {"Terms by etymology subcategories by language"}},
		    	{"%l onomatopoeias", {"%l terms by etymology", "Onomatopoeias by language"}},
		    {"Rebracketings by language", {"Terms by etymology subcategories by language"}},
	    	    {"%l rebracketings", {"%l terms by etymology", "Rebracketings by language"}},
		    {"Reduplications by language", {"Terms by etymology subcategories by language"}},
		    	{"%l reduplications", {"%l terms by etymology", "Reduplications by language"}},
	    	{"Univerbations by language", {"Terms by etymology subcategories by language"}},
		    	{"%l univerbations", {"%l terms by etymology", "Univerbations by language"}},
		    {"Terms with uncertain etymologies by language", {"Terms by etymology subcategories by language"}},
		    	{"%l terms with uncertain etymologies", {"%l terms by etymology", "Terms with uncertain etymologies by language"}},
		    {"Terms with unknown etymologies by language", {"Terms by etymology subcategories by language"}},
		    	{"%l terms with unknown etymologies", {"%l terms by etymology", "Terms with unknown etymologies by language"}},
		    {"Terms with multiple etymologies by language", {"Terms by etymology subcategories by language"}},
		    	{"%l terms with multiple etymologies", {"%l terms by etymology", "Terms with multiple etymologies by language"}},
		    {"Verbalisations by language", {"Terms by etymology subcategories by language"}},
    			{"%l verbalisations", {"%l terms by etymology", "Verbalisations by language"}},
		{"%l terms by etymology", {"%l language| ", "Terms by etymology by language"}},

    -- Etymology source by language
    {"Terms derived from %l", {"%l language| "}},
    	{"%l terms derived from %u", {"Terms derived from %u"}},
    	{"Terms borrowed from %l", {"Terms derived from %l", "Borrowed terms by language"}},
    {"Inherited terms by language", {"Terms by etymology subcategories by language"}},
    	{"%l inherited terms", {"%l terms by etymology| ", "Inherited terms by language"}},
    {"Borrowed terms by language", {"Terms by etymology subcategories by language"}},
    	{"%l borrowed terms", {"%l terms by etymology| ", "Borrowed terms by language"}},
    		{"%l terms borrowed from %s", {"%l borrowed terms| ", "%l terms derived from %s| ", "Terms borrowed from %s"}},
    		{"%l orthographic borrowings", {"%l borrowed terms| ", "Orthographic borrowings by language"}},
    	{"Orthographic borrowings from %s by language", {"Terms borrowed from %s| ", "Borrowed terms by language"}},
		{"Semantic loans from %s", {"Terms borrowed from %s| ", "Borrowed terms by language"}},
		{"Phono-semantic matchings from %s", {"Terms borrowed from %s| ", "Borrowed terms by language"}},
		{"Transliterations of %s", {"Terms borrowed from %s| ", "Borrowed terms by language"}},
    {"Calques by language", {"Terms by etymology subcategories by language"}},
    	{"%l calques", {"%l terms by etymology", "Calques by language"}},
    		{"%l terms calqued from %s", {"%l calques", "%l terms borrowed from %s", "Terms calqued from %s"}},
    {"Terms inherited from %s", {"Terms derived from %s", "Inherited terms by language"}},
    	{"%l terms inherited from %s", {"%l inherited terms", "%l terms derived from %s", "Terms inherited from %s"}},
    {"Terms calqued from %s", {"Terms borrowed from %s", "Borrowed terms by language"}},
    {"Learned borrowings by language", {"Terms by etymology subcategories by language"}},
    	{"Learned borrowings from %s by language", {"Terms borrowed from %s", "Borrowed terms by language"}},
    			{"%l learned borrowings from %s", {"%l learned borrowings", "%l terms borrowed from %s", "Learned borrowings from %s by language"}},
		{"%l learned borrowings", {"%l borrowed terms", "Learned borrowings by language"}},
    {"Orthographic borrowings by language", {"Terms by etymology subcategories by language"}},
    	{"%l orthographic borrowings from %s", {"%l orthographic borrowings", "%l terms borrowed from %s", "Orthographic borrowings from %s by language"}},
    {"Semantic loans by language", {"Terms by etymology subcategories by language"}},
    	{"%l semantic loans", {"%l borrowed terms", "Semantic loans by language"}},
    		{"%l semantic loans from %s", {"%l semantic loans", "%l terms borrowed from %s", "Semantic loans from %s"}},
    {"Phono-semantic matchings by language", {"Terms by etymology subcategories by language"}},
    	{"%l phono-semantic matchings", {"%l borrowed terms", "Phono-semantic matchings by language"}},
    		{"%l phono-semantic matchings from %s", {"%l phono-semantic matchings", "%l terms borrowed from %s", "Phono-semantic matchings from %s"}},
    {"Transliterations by language", {"Terms by etymology subcategories by language"}},
    	{"%l transliterations", {"%l borrowed terms", "Transliterations by language"}},
    		{"%l transliterations of %s", {"%l transliterations", "%l terms borrowed from %s", "Transliterations of %s"}},

    -- Affix etymology
    {"Compound terms by language", {"Terms by etymology subcategories by language"}},
    	{"%l compound terms", {"%l terms by etymology|compound terms", "Compound terms by language"}},
    		{"%l %s compounds", {"%l compound terms|%s"}},
    {"Terms by prefix by language", {"Terms by etymology subcategories by language"}},
    	{"%l terms by prefix", {"%l prefixes| ", "%l terms by etymology| ", "Terms by prefix by language"}},
    		{"%l terms prefixed with %s", {"%l terms by prefix| "}},
    {"Terms by suffix by language", {"Terms by etymology subcategories by language"}},
    	{"%l terms by suffix", {"%l suffixes| ", "%l terms by etymology| ", "Terms by suffix by language"}},
    		{"%l terms suffixed with %s", {"%l terms by suffix| "}},
    {"Terms by infix by language", {"Terms by etymology subcategories by language"}},
    	{"%l terms by infix", {"%l infixes| ", "%l terms by etymology| ", "Terms by infix by language"}},
    		{"%l terms infixed with %s", {"%l terms by infix| "}},
    {"Terms by circumfix by language", {"Terms by etymology subcategories by language"}},
    	{"%l terms by circumfix", {"%l circumfixes| ", "%l terms by etymology| ", "Terms by circumfix by language"}},
    		{"%l terms circumfixed with %s", {"%l terms by circumfix| "}},

    -- Coinage
    {"Coinages by language", {"Terms by etymology subcategories by language"}},
    {"%l coinages", {"%l terms by etymology", "Coinages by language"}},
    
    -- Entry maintenance
    {"Entry maintenance", {"Fundamental| "}},
    	{"Terms which require adding to also data", {"Entry maintenance| "}},
	    {"Pages using outdated templates", {"Entry maintenance| "}},
	    {"Category pages not matched by auto cat", {"Entry maintenance| "}},
	    {"Translations to update", {"Entry maintenance| "}},
	    {"Etymology headings to update", {"Entry maintenance| "}},
	    {"Entry maintenance by language", {"Entry maintenance| "}},
		    {"Terms with usage examples by language", {"Entry maintenance by language| "}},
		    {"%l entry maintenance", {"%l language| ", "Entry maintenance by language"}},
		    	{"%l terms with manually entered pronunciation", {"%l entry maintenance| "}},
		    {"%l terms with usage examples", {"%l entry maintenance| ", "Terms with usage examples by language"}},
		    
		    {"Terms with translations by language", {"Entry maintenance by language| "}},
		    	{"%l terms with translations", {"Terms with translations by language"}},
		    	{"Terms with %l translations by language", {"Terms with translations by language|%l"}},
		    		{"%l terms with %u translations", {"%l terms with translations", "Terms with %u translations by language"}},
		    {"Terms needing %l translations", {"Entry maintenance by language| "}},	
		    
		    {"%l terms missing %s", {"%l entry maintenance"}},
		    {"%l terms needing %s", {"%l entry maintenance"}},
		    {"%l terms without %s", {"%l entry maintenance"}},
    
    -- Miscellaneous terms (custom)
    {"Homophones by language", {"Fundamental| "}},
    	{"%l homophones", {"%l language| ", "Homophones by language"}},
    {"Interlingual homographs", {"Fundamental| "}},
    {"Requested terms by language", {"Fundamental| "}},
    	{"%l requested terms", {"%l language| ", "Requested terms by language"}},
    		{"%l terms requested by my %s", {"%l requested terms"}},
    {"Nth terms by language", {"Fundamental| "}},
    	{"%l nth terms", {"%l language| ", "Nth terms by language"}},
    
    -- Usage labels by language
    	-- Language usage labels
    {"Terms by usage by language", {"Fundamental| "}},
    	{"%l terms by usage", {"%l language| ", "Terms by usage by language"}},
    {"Terms by usage subcategories by language", {"Terms by usage by language| "}},
	    {"Archaic terms by language", {"Terms by usage subcategories by language"}},
	    	{"%l archaic terms", {"%l terms by usage", "Archaic terms by language"}},
	    {"Colloquial terms by language", {"Terms by usage subcategories by language"}},
	    	{"%l colloquial terms", {"%l terms by usage", "Colloquial terms by language"}},
	    {"Dated terms by language", {"Terms by usage subcategories by language"}},
	    	{"%l dated terms", {"%l terms by usage", "Dated terms by language"}},
	    {"Derogatory terms by language", {"Terms by usage subcategories by language"}},
	    	{"%l derogatory terms", {"%l terms by usage", "Derogatory terms by language"}},
	    {"Dialectal terms by language", {"Terms by usage subcategories by language"}},
	    	{"%l dialectal terms", {"%l terms by usage", "Dialectal terms by language"}},
	    {"Euphemisms by language", {"Terms by usage subcategories by language"}},
	    	{"%l euphemisms", {"%l terms by usage", "Euphemisms by language"}},
	    {"Formal terms by language", {"Terms by usage subcategories by language"}},
	    	{"%l formal terms", {"%l terms by usage", "Formal terms by language"}},
	    {"Gender-neutral terms by language", {"Terms by usage subcategories by language"}},
	    	{"%l gender-neutral terms", {"%l terms by usage", "Gender-neutral terms by language"}},
	    {"Humble terms by language", {"Terms by usage subcategories by language"}},
	    	{"%l humble terms", {"%l terms by usage", "Humble terms by language"}},
    	{"Idioms by language", {"Terms by usage subcategories by language"}},
	    	{"%l idioms", {"%l terms by usage", "Idioms by language"}},
	    {"Jocular terms by language", {"Terms by usage subcategories by language"}},
	    	{"%l jocular terms", {"%l terms by usage", "Jocular terms by language"}},
	    {"Obsolete terms by language", {"Terms by usage subcategories by language"}},
	    	{"%l obsolete terms", {"%l terms by usage", "Obsolete terms by language"}},
	    {"Offensive terms by language", {"Terms by usage subcategories by language"}},
	    	{"%l offensive terms", {"%l terms by usage", "Offensive terms by language"}},
	    {"Pejorative terms by language", {"Terms by usage subcategories by language"}},
	    	{"%l pejorative terms", {"%l terms by usage", "Pejorative terms by language"}},
	    {"Slang terms by language", {"Terms by usage subcategories by language"}},
	    	{"%l slang terms", {"%l terms by usage", "Slang terms by language"}},
	    {"Slurs by language", {"Terms by usage subcategories by language"}},
	    	{"%l slurs", {"%l terms by usage", "Slurs by language"}},
	    {"Vulgar terms by language", {"Terms by usage subcategories by language"}},
			{"%l vulgar terms", {"%l terms by usage", "Vulgar terms by language"}},
    -- Templates
    {"Templates", {"Fundamental| "}},
    {"Template documentation", {"Templates| "}},
    {"Documentation subpages", {"Fundamental| ", "Templates| ", "Modules| "}},
    {"Templates by language", {"Templates"}},
    {"Entry templates", {"Templates"}},
    {"Link templates", {"Templates"}},
    {"Banner templates", {"Templates"}},
    {"Encyclopedia templates", {"Templates"}},
    {"Meta", {"Templates"}},
    {"Etymology templates", {"Entry templates"}},
    {"Definition templates", {"Entry templates"}},
    {"Pronunciation templates", {"Entry templates"}},
    {"Translation templates", {"Entry templates"}},
    {"%l templates", {"Templates by language"}},
    {"%s templates", {"Templates"}},
    -- Modules
    {"Modules", {"Fundamental| "}},
    {"Modules by language", {"Modules"}},
    {"%l modules", {"Modules by language"}},
    -- Topics
    {"Topics by language", {"Fundamental| "}},
    	{"In-world terms by language", {"Topics by language"}},
    	{"Out-of-world terms by language", {"Topics by language"}},
    	{"%l topics", {"%l language| ", "Topics by language| "}},
    -- Topic subcategories 
    	-- World specificity
	    {"%l in-world terms", {"%l topics| ", "In-world terms by language"}},
	    {"%l out-of-world terms", {"%l topics| ", "Out-of-world terms by language"}},
	    -- Names
	    {"%l names", {"%l topics| ", "Names by language"}},
	    	{"%l given names", {"Given names by language", "%l names| "}},
	    		{"%l %s given names", {"%s given names by language", "%l given names| "}},
	    	{"%l surnames", {"Surnames by language", "%l names| "}},
	    		{"%l %s surnames", {"%s surnames by language", "%l surnames| "}},
	    	
    	{"Names by language", {"Topics by language"}},
    		{"Given names by language", {"Names by language| "}},
    			{"%s given names by language", {"Given names by language| "}},
    		{"Surnames by language", {"Names by language| "}},
    			{"%s surnames by language", {"Surnames by language| "}},
    		
		{"%l names %s", {"%l names| "}},
			
	-- Sort other term descriptors as lemma subcategories (needs to be at the end)
		{"%s terms by language", {"Lemmas subcategories by language"}},
	    {"%l comparable terms", {"%l language| ", "Comparable terms by language"}},
    	{"%l comparable %ps", {"%l %ps| ", "Comparable terms by language"}},
	    {"%l uncomparable terms", {"%l language| ", "Uncomparable terms by language"}},
	    {"%l %s terms", {"%l language| ", "%s terms by language"}},
		{"%l uncomparable terms", {"%l language| ", "Uncomparable terms by language"}},
		{"%l %ps %s", {"%l %ps| "}},
}

-- provides initial capitalisation
local function capitalize(word)
	if mw.ustring.len(word) > 1 then
		return mw.ustring.upper(mw.ustring.sub(word, 1, 1))	.. mw.ustring.sub(word, 2)
	elseif mw.ustring.len(word) == 1 then
		return mw.ustring.upper(word)
	end
	error("Empty input for capitalisation")
end

-- process subtopics

for subtopic, supertopics in pairs(subtopics) do
	local subcats = {"%l topics|" .. subtopic, capitalize(subtopic) .. " topic by language| "}
	local subcats_topic = {"Topics by language"}
	if type(supertopics) == "string" then
		table.insert(subcats, "%c:" .. capitalize(supertopics) .. "|" .. subtopic)
		table.insert(subcats_topic, capitalize(supertopics) .. " topic by language")
	elseif type(supertopics) == "table" then
		for _, supertopic in ipairs(supertopics) do
			table.insert(subcats, "%c:" .. capitalize(supertopic) .. "|" .. subtopic)
			table.insert(subcats_topic, capitalize(supertopic) .. " topic by language")
		end
	end
	table.insert(cats, {capitalize(subtopic) .. " topic by language", subcats_topic})
	table.insert(cats, {"%c:" .. capitalize(subtopic), subcats})
end
table.insert(cats, {"%s topic by language", {"Topics by language"}})
table.insert(cats, {"%c:%s", {"%l topics|%s", "%s topic by language| "}})


return {
	cats = cats,
	pos = pos,
}