Module:User:Erutuon/syllables/sandbox

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

This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local export = {}

local U = mw.ustring.char
local UTF8_char = "*"

local function characters_to_set(str)
	local set = {}
	for character in string.gmatch(str, UTF8_char) do
		set = true
	end
	return set
end

local function make_set(...)
	if select(2, ...) then
		local set = {}
		for i, char in ipairs{ ... } do
			set = true
		end
		return set
	else
		return characters_to_set(select(1, ...))
	end
end

local info = {}
info.is_vowel = make_set "iyɨʉɯuɪʏʊeøɘɵɤoəɚɛœɜɝɞʌɔæɐaɶɑɒäëïöüÿ"
info.nonsyllabic = make_set(U(0x311), U(0x32F))

function export.count(IPA)
	local count = 0
	local prev
	for character in string.gmatch(IPA, UTF8_char) do
		if info.is_vowel then
			count = count + 1
		elseif info.nonsyllabic then
			count = count - 1
		end
		prev = character
	end
	return count
end

mw.logObject(info)

return export