<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://linguifex.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AUnicode_data%2Fdatasets</id>
	<title>Module:Unicode data/datasets - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://linguifex.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AUnicode_data%2Fdatasets"/>
	<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:Unicode_data/datasets&amp;action=history"/>
	<updated>2026-05-23T14:15:24Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://linguifex.com/w/index.php?title=Module:Unicode_data/datasets&amp;diff=515685&amp;oldid=prev</id>
		<title>Sware: Created page with &quot;local export = {}  --[==[ Fetches a data set from Wikimedia Commons by the name `dataset_name`, parses it as a Unicode character key-value table, and returns that table.  The table is assumed to have at least two fields with the `name` fields set to `key` and `value`. Both values are expected to be strings. The key string is parsed as a hexadecimal numeric literal (e.g. `0x1234`) and converted into a number.  The table returned will then have numbers as the keys and stri...&quot;</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:Unicode_data/datasets&amp;diff=515685&amp;oldid=prev"/>
		<updated>2026-05-08T11:58:37Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;local export = {}  --[==[ Fetches a data set from Wikimedia Commons by the name `dataset_name`, parses it as a Unicode character key-value table, and returns that table.  The table is assumed to have at least two fields with the `name` fields set to `key` and `value`. Both values are expected to be strings. The key string is parsed as a hexadecimal numeric literal (e.g. `0x1234`) and converted into a number.  The table returned will then have numbers as the keys and stri...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local export = {}&lt;br /&gt;
&lt;br /&gt;
--[==[&lt;br /&gt;
Fetches a data set from Wikimedia Commons by the name `dataset_name`, parses it as a Unicode character key-value table, and returns that table.&lt;br /&gt;
&lt;br /&gt;
The table is assumed to have at least two fields with the `name` fields set to `key` and `value`. Both values are expected to be strings. The key string is parsed as a hexadecimal numeric literal (e.g. `0x1234`) and converted into a number.&lt;br /&gt;
&lt;br /&gt;
The table returned will then have numbers as the keys and strings as the values.]==]&lt;br /&gt;
function export.dataset(dataset_name)&lt;br /&gt;
	local dataset = mw.ext.data.get(dataset_name)&lt;br /&gt;
	&lt;br /&gt;
	if not dataset then error(&amp;quot;Dataset &amp;quot; .. dataset_name .. &amp;quot; not found&amp;quot;) end&lt;br /&gt;
	&lt;br /&gt;
	-- Check schema.&lt;br /&gt;
	local charcode_index = nil&lt;br /&gt;
	local value_index = nil&lt;br /&gt;
	for index, field in ipairs(dataset.schema.fields) do&lt;br /&gt;
		local field_name_lower = field.name:lower()&lt;br /&gt;
		if field_name_lower:find(&amp;quot;key&amp;quot;) and field.type == &amp;quot;string&amp;quot; then&lt;br /&gt;
			charcode_index = index&lt;br /&gt;
		elseif field_name_lower:find(&amp;quot;value&amp;quot;) and field.type == &amp;quot;string&amp;quot; then&lt;br /&gt;
			value_index = index&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if not charcode_index then error(&amp;quot;Character code field (name=&amp;#039;key&amp;#039;, type=&amp;#039;string&amp;#039;) not found in data schema.&amp;quot;) end&lt;br /&gt;
	if not value_index then error(&amp;quot;Value field (name=&amp;#039;value&amp;#039;, type=&amp;#039;string&amp;#039;) not found in data schema.&amp;quot;) end&lt;br /&gt;
	&lt;br /&gt;
	-- Extract values from dataset data.&lt;br /&gt;
	local result = {}&lt;br /&gt;
	for _, item in ipairs(dataset.data) do&lt;br /&gt;
		result[tonumber(item[charcode_index])] = item[value_index]&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return export&lt;/div&gt;</summary>
		<author><name>Sware</name></author>
	</entry>
</feed>