Module:zh/data/nan-pron/list

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

Generates lists of items in Min Nan pronunciation data modules, such as Module:zh/data/nan-pron/000.


local export = {}

local sortedPairs = require("Module:table").sortedPairs
local UTF8_char = "*"

-- Based on tone_to_mark in ], but omits final stops.
local tone_to_number = {
	 = "1",
	 = "2",
	 = "3",
	 = "5",
	 = "6",
	 = "7",
	 = "8",
	 = "9",
}

local decompose = mw.ustring.toNFD
local prepare = require("Module:memoize")(function(item) -- Converts tones to numbers and hopefully puts them at end of syllable.
	return decompose(item)
		:lower()
		:gsub(UTF8_char, tone_to_number)
		:gsub("()(+)", "%2%1")
		:gsub("()ⁿ", "ⁿ%1")
end, true)

local function compare(item1, item2)
	return prepare(item1) < prepare(item2)
end

local function add(t, v)
	t.n = t.n + 1
	t = v
end

function export.show(frame)
	local number = frame.args
	local list = require("Module:zh/data/nan-pron/"..number)
	local results = {}
	local old_module = number == "-019"
	if old_module then
		for key in sortedPairs(list, compare) do
			local current = prepare(key:match(UTF8_char))
			if not results then
				results = ""
			else
				results = results .. "] "
			end
		end
	else
		-- Key is Han characters, value is Pe̍h-ōe-jī.
		for key, val in sortedPairs(list, compare) do
			local current = prepare(val:match(UTF8_char))
			if not results then
				results = { n = 0 }
			else
				add(results, "]")
			end
		end
	end
	
	local result = {}
	local i = 0
	if old_module then
		for _, val in sortedPairs(results) do
			i = i + 1
			result = val
		end
	else
		for _, val in sortedPairs(results) do
			i = i + 1
			result = table.concat(val, " ")
		end
	end
	
	return table.concat(result, "\n\n")
end

return export