<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.2swagg.net/index.php?action=history&amp;feed=atom&amp;title=Module%3AInfobox_categorizer%2Fdoc</id>
	<title>Module:Infobox categorizer/doc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.2swagg.net/index.php?action=history&amp;feed=atom&amp;title=Module%3AInfobox_categorizer%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://wiki.2swagg.net/index.php?title=Module:Infobox_categorizer/doc&amp;action=history"/>
	<updated>2026-11-13T00:57:29Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.9</generator>
	<entry>
		<id>https://wiki.2swagg.net/index.php?title=Module:Infobox_categorizer/doc&amp;diff=1588&amp;oldid=prev</id>
		<title>Bulgogi2: Created page with &quot;{{Module rating|beta}}  {{lua|Module:WikitextParser |Module:yesno |Module:CatMark}}  This module is a shared toolkit metamodule for modules that assign categories from infobox parameters. It provides the ability to &quot;read&quot; infobox fields, matching aliases, handling overrides and suppression, and creating category links. This module does not decide what the information it reads means, instead, submodules specifically tailored for an infobox must supply that logic and inter...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.2swagg.net/index.php?title=Module:Infobox_categorizer/doc&amp;diff=1588&amp;oldid=prev"/>
		<updated>2026-10-11T01:09:11Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Module rating|beta}}  {{lua|Module:WikitextParser |Module:yesno |Module:CatMark}}  This module is a shared toolkit metamodule for modules that assign categories from infobox parameters. It provides the ability to &amp;quot;read&amp;quot; infobox fields, matching aliases, handling overrides and suppression, and creating category links. This module does not decide what the information it reads means, instead, submodules specifically tailored for an infobox must supply that logic and inter...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Module rating|beta}}&lt;br /&gt;
&lt;br /&gt;
{{lua|Module:WikitextParser&lt;br /&gt;
|Module:yesno&lt;br /&gt;
|Module:CatMark}}&lt;br /&gt;
&lt;br /&gt;
This module is a shared toolkit metamodule for modules that assign categories from infobox parameters. It provides the ability to &amp;quot;read&amp;quot; infobox fields, matching aliases, handling overrides and suppression, and creating category links. This module does not decide what the information it reads means, instead, submodules specifically tailored for an infobox must supply that logic and interpretation. Submodules must also decide which configuration(s) to load{{Note|No records are loaded automatically. You can find a &amp;quot;registrar list&amp;quot; of records as subpages of this module or in a list below.}}{{Note|When compiling provided alias sets, earlier sets will have priority over later sets for the same alias or domain, &amp;quot;ownership&amp;quot;. Beware!}}, and which categories to add. The toolkit does not render an infobox, nor does it have a main function. Therefore, it cannot be invoked directly, per design.&lt;br /&gt;
&lt;br /&gt;
== reading infobox values ==&lt;br /&gt;
{{Tip|You need to have some experience with [[Lua]] to be able to understand anything below this section, or if you want to make a submodule.}}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
&lt;br /&gt;
! function&lt;br /&gt;
&lt;br /&gt;
! result&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| &amp;lt;code&amp;gt;trim(value)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| Converts a value to trimmed text. &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; becomes an empty string.&lt;br /&gt;
&lt;br /&gt;
|-well&lt;br /&gt;
&lt;br /&gt;
| &amp;lt;code&amp;gt;normalize(value, mode)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| Lowercases text. Default or &amp;lt;code&amp;gt;compact&amp;lt;/code&amp;gt; removes nonword characters. &amp;lt;code&amp;gt;spaced&amp;lt;/code&amp;gt; replaces runs of them with spaces, if you need that.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|&amp;lt;code&amp;gt;clean(value)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| Returns text for matching. It will remove references, hidden markers, comments, and tags. It substitutes displayed wikilink text and external link labels removes bare HTTP(S) urls and decodes entities. It is an analysis aid only.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| &amp;lt;code&amp;gt;findYears(value)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| finds distinct{{Note|Read more on Lua frontier patterns to understand what this means exactly.}} four-digit years in the cleaned text, in encounter order.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;findYearRanges(value)&amp;lt;/code&amp;gt;&lt;br /&gt;
| if the parameter you want to read recommends years be entered as YYYY - YYYY, use this function. It will find all distinct pairs, returning, for example, &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{&amp;#039;2020&amp;#039;, &amp;#039;2022&amp;#039;}, ...}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; . It does not expand or interpret ranges. -, em dash, whatever dash, all are supported.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;findLinkTargets(value, opts)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| Returns distinct wikilink targets as prefixed page titles, ignoring display labels, refs, and fragments. Defaults to namespace &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;opts.namespaces&amp;lt;/code&amp;gt; changes the allowed list. &amp;#039;&amp;#039;&amp;#039;It does not resolve redirects&amp;#039;&amp;#039;&amp;#039;{{Note|Avoid redirects with this thing like the plague, avoid redirects in general}}&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| &amp;lt;code&amp;gt;[[Module:CatMark|readDataAttr]](value, name)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| Reads all &amp;lt;code&amp;gt;data-cat-&amp;#039;&amp;#039;name&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; attribute values produced by [[Module:CatMark]]. Returns a list of decoded strings. The name argument may only contain letters, digits, and hyphens. Read CatMark to learn more about using it.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| &amp;lt;code&amp;gt;parseNumber(value)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| Parses a [[autism|signed decimal number]] after removing commas and whitespace. Returns &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; if invalid.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
| &amp;lt;code&amp;gt;pickBand(number, bands)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
| Finds the eligible &amp;quot;band&amp;quot; with the greatest &amp;lt;code&amp;gt;min&amp;lt;/code&amp;gt; and returns its &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt;. Returns &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; if none qualifies.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For &amp;lt;code&amp;gt;pickBand&amp;lt;/code&amp;gt;, keep in mind that bands are records such as &amp;lt;code&amp;gt;{min=100, name = &amp;#039;100 SoyBooru posts&amp;#039;}&amp;lt;/code&amp;gt;. In other words, the subject module decides which number to read and whether a band category applies.&lt;br /&gt;
== Alias set handling ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;compileAliasSet(sets, options)&amp;lt;/code&amp;gt; (reported as CAS in errors) compiles an ordered list of sets. Each set is a list of category records, with aliases and, optionally, domains identifying each category. For CAS to function, &amp;#039;&amp;#039;&amp;#039;sets must be wrapped, even if there is just one.&amp;#039;&amp;#039;&amp;#039; Wrap them like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
local subjectSites = {&lt;br /&gt;
&lt;br /&gt;
{ category = &amp;#039;4chan&amp;#039;, aliases = { &amp;#039;4chan&amp;#039;, &amp;#039;4cuck&amp;#039; }, domains = { &amp;#039;4chan.org&amp;#039; } },&lt;br /&gt;
&lt;br /&gt;
{ category = &amp;#039;Soyjak.party&amp;#039;, aliases = { &amp;#039;sharty&amp;#039;, &amp;#039;soyjak.party&amp;#039; } },&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
local sharedSites = mw.loadData(&amp;#039;Module:Infobox categorizer/sites&amp;#039;)&lt;br /&gt;
local sites = core.compileAliasSet({ subjectSites, sharedSites })&lt;br /&gt;
local matches = core.matchAliasSets(args.frequented_sites, sites)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The order of the sets determine priority. The first set to claim an alias or domain will own that claim, later sets cannot assign the same claim to another category, in other words, that claim is occupied. Putting a subject&amp;#039;s records before shared records lets the subject override &amp;quot;global&amp;quot; records. As an example, if a country set assigns &amp;quot;Frog&amp;quot; as an alias to France, and NAS sets &amp;quot;Frog&amp;quot; to Pepe, and both are loaded with the same matching mode &amp;amp; case setting (defaults mean this is likely, read more below), whichever set comes first will own &amp;quot;Frog&amp;quot;. Keep this in mind with complicated infoboxes, since as time passes the list of aliases will grow and conflicting sets will become inevitable. You must choose what are the appropriate sets to load and their order.&lt;br /&gt;
&lt;br /&gt;
After compilation, &amp;lt;code&amp;gt;matchAliasSets(value, compiled)&amp;lt;/code&amp;gt; (reported as MAS in errors) searches an input for the compiled aliases and domains. It returns every matching category once. For example, an input containing &amp;quot;4cuck&amp;quot; and &amp;quot;sharty&amp;quot; can return both &amp;quot;4chan&amp;quot; and &amp;quot;soyjak.party&amp;quot;. MAS returns allow the subject module to categorize a field containing several sites, countries, or other recognized values. Record with the same category label are merged during compilation.&lt;br /&gt;
&lt;br /&gt;
{{Bantext|Within a single set, two different categories cannot claim the same alias after normalization}}{{Note|Under the same matching mode and case setting.}} or the same normalized domain. This is because each alias claim within a set must have one owner. Assigning &amp;quot;Frog&amp;quot; to both France and Pepe is contradictory, so CAS rejects the set with a config error. To fix this, remove or reassign the duplicate alias. If the competing sets are intentional, place them in separate sets and sort them by priority. In separately loaded sets, the conflicts are resolved by load order.&lt;br /&gt;
&lt;br /&gt;
An alias can be a string or a record containing additional matching settings if the situation calls for it. For example, the country code for the United States is &amp;quot;US&amp;quot;. To avoid false flag detection of &amp;quot;us&amp;quot;, making &amp;quot;US&amp;quot; case sensitive prevents lowercase &amp;quot;us&amp;quot; from matching and exact matching requires the entire field to be &amp;quot;US&amp;quot; only. This is done with &amp;lt;code&amp;gt;{&amp;#039;US&amp;#039;, match = &amp;#039;exact&amp;#039;, caseSensitive = true}&amp;lt;/code&amp;gt;{{Note|Remember, wiki content is extremely unpredictable and things that seem minute as this are still a key issue that you have to consider.}} The matching mode setting can be supplied through &amp;lt;code&amp;gt;options.match&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;set.match&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;entry.match&amp;lt;/code&amp;gt;, or the individual alias &amp;lt;code&amp;gt;match&amp;lt;/code&amp;gt; setting. The more specific setting wins, the individual alias always has the highest priority. The default mode is &amp;lt;code&amp;gt;word&amp;lt;/code&amp;gt;. Case sensitive-matching is enabled through &amp;lt;code&amp;gt;caseSensitive = true&amp;lt;/code&amp;gt; on a record.&lt;br /&gt;
&lt;br /&gt;
more snca to add later&lt;br /&gt;
{{notelist}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;includeonly&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Titles namespaces and categories modules]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Utility modules]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bulgogi2</name></author>
	</entry>
</feed>