<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://academia.la/w/index.php?action=history&amp;feed=atom&amp;title=Module%3Asyllables</id>
	<title>Module:syllables - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://academia.la/w/index.php?action=history&amp;feed=atom&amp;title=Module%3Asyllables"/>
	<link rel="alternate" type="text/html" href="https://academia.la/w/index.php?title=Module:syllables&amp;action=history"/>
	<updated>2026-04-17T03:14:43Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://academia.la/w/index.php?title=Module:syllables&amp;diff=1502&amp;oldid=prev</id>
		<title>Jācōbus: Created page with &quot;local export = {}  local diphthongs = mw.loadData(&quot;Module:IPA/data&quot;).diphthongs local vowels = mw.loadData(&quot;Module:IPA/data/symbols&quot;).vowels .. &quot;ᵻ&quot; .. &quot;ᵿ&quot;  local U = mw.ustring.char  --[[ No use for this at the moment, though it is an interesting catalogue. 	It might be usable for phonetic transcriptions. 	Diacritics added to vowels: 	inverted breve above, inverted breve below, 	up tack, down tack, 	left tack, right tack, 	diaeresis (above), diaeresis below, 	right h...&quot;</title>
		<link rel="alternate" type="text/html" href="https://academia.la/w/index.php?title=Module:syllables&amp;diff=1502&amp;oldid=prev"/>
		<updated>2023-02-07T23:06:38Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;local export = {}  local diphthongs = mw.loadData(&amp;quot;Module:IPA/data&amp;quot;).diphthongs local vowels = mw.loadData(&amp;quot;Module:IPA/data/symbols&amp;quot;).vowels .. &amp;quot;ᵻ&amp;quot; .. &amp;quot;ᵿ&amp;quot;  local U = mw.ustring.char  --[[ No use for this at the moment, though it is an interesting catalogue. 	It might be usable for phonetic transcriptions. 	Diacritics added to vowels: 	inverted breve above, inverted breve below, 	up tack, down tack, 	left tack, right tack, 	diaeresis (above), diaeresis below, 	right h...&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;
local diphthongs = mw.loadData(&amp;quot;Module:IPA/data&amp;quot;).diphthongs&lt;br /&gt;
local vowels = mw.loadData(&amp;quot;Module:IPA/data/symbols&amp;quot;).vowels .. &amp;quot;ᵻ&amp;quot; .. &amp;quot;ᵿ&amp;quot;&lt;br /&gt;
&lt;br /&gt;
local U = mw.ustring.char&lt;br /&gt;
&lt;br /&gt;
--[[ No use for this at the moment, though it is an interesting catalogue.&lt;br /&gt;
	It might be usable for phonetic transcriptions.&lt;br /&gt;
	Diacritics added to vowels:&lt;br /&gt;
	inverted breve above, inverted breve below,&lt;br /&gt;
	up tack, down tack,&lt;br /&gt;
	left tack, right tack,&lt;br /&gt;
	diaeresis (above), diaeresis below,&lt;br /&gt;
	right half ring, left half ring,&lt;br /&gt;
	plus sign below, minus sign below,&lt;br /&gt;
	combining x above, rhotic hook,&lt;br /&gt;
	tilde (above), tilde below&lt;br /&gt;
	ligature tie (combining double breve), ligature tie below&lt;br /&gt;
	]]&lt;br /&gt;
local diacritics = U(0x311)..U(0x32F)&lt;br /&gt;
	..U(0x31D)..U(0x31E)&lt;br /&gt;
	..U(0x318)..U(0x319)&lt;br /&gt;
	..U(0x308)..U(0x324)&lt;br /&gt;
	..U(0x339)..U(0x31C)&lt;br /&gt;
	..U(0x31F)..U(0x320)&lt;br /&gt;
	..U(0x33D)..U(0x2DE)&lt;br /&gt;
	..U(0x303)..U(0x330)&lt;br /&gt;
	..U(0x361)..U(0x35C)&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
combining acute and grave tone marks, circumflex&lt;br /&gt;
]]--&lt;br /&gt;
local tone = &amp;quot;[&amp;quot; .. U(0x341) .. U(0x340) ..U (0x302) .. &amp;quot;]&amp;quot;&lt;br /&gt;
local nonsyllabicDiacritics = U(0x311) .. U(0x32F)&lt;br /&gt;
local syllabicDiacritics = U(0x0329) .. U(0x030D)&lt;br /&gt;
local ties = U(0x361) .. U(0x35C)&lt;br /&gt;
&lt;br /&gt;
-- long, half-long, extra short&lt;br /&gt;
local lengthDiacritics = U(0x2D0) .. U(0x2D1) .. U(0x306)&lt;br /&gt;
local vowel = &amp;quot;[&amp;quot; .. vowels .. &amp;quot;]&amp;quot; .. tone .. &amp;quot;?&amp;quot;&lt;br /&gt;
local tie = &amp;quot;[&amp;quot; .. ties .. &amp;quot;]&amp;quot;&lt;br /&gt;
local nonsyllabicDiacritic = &amp;quot;[&amp;quot; .. nonsyllabicDiacritics .. &amp;quot;]&amp;quot;&lt;br /&gt;
local syllabicDiacritic = &amp;quot;[&amp;quot; .. syllabicDiacritics .. &amp;quot;]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
local UTF8Char = &amp;quot;[\1-\127\194-\244][\128-\191]*&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function export.getVowels(remainder, lang)&lt;br /&gt;
	if string.find(remainder, &amp;quot;^[%\[/]?%-&amp;quot;) or string.find(remainder, &amp;quot;%-[%\[/]?$&amp;quot;) then&lt;br /&gt;
		return nil&lt;br /&gt;
	end	-- If a hyphen is at the beginning or end of the transcription, do not count syllables.&lt;br /&gt;
	&lt;br /&gt;
	local count = 0&lt;br /&gt;
	local diphs = diphthongs[lang:getCode()] or {}&lt;br /&gt;
	&lt;br /&gt;
	remainder = mw.ustring.toNFD(remainder)&lt;br /&gt;
	remainder = string.gsub(remainder, &amp;quot;%((.*)%)&amp;quot;, &amp;quot;%1&amp;quot;) -- Remove parentheses.&lt;br /&gt;
&lt;br /&gt;
	while remainder ~= &amp;quot;&amp;quot; do&lt;br /&gt;
		-- Ignore nonsyllabic vowels&lt;br /&gt;
		remainder = mw.ustring.gsub(remainder, &amp;quot;^&amp;quot; .. vowel .. nonsyllabicDiacritic, &amp;quot;&amp;quot;)&lt;br /&gt;
		&lt;br /&gt;
		local m =&lt;br /&gt;
			mw.ustring.match(remainder, &amp;quot;^.&amp;quot; .. syllabicDiacritic) or  -- Syllabic consonant&lt;br /&gt;
			mw.ustring.match(remainder, &amp;quot;^&amp;quot; .. vowel .. tie .. vowel)  -- Tie bar&lt;br /&gt;
		&lt;br /&gt;
		-- Starts with a recognised diphthong?&lt;br /&gt;
		for _, diph in ipairs(diphs) do&lt;br /&gt;
			if m then&lt;br /&gt;
				break&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			m = m or mw.ustring.match(remainder, &amp;quot;^&amp;quot; .. diph)&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		-- If we haven't found anything yet, just match on a single vowel&lt;br /&gt;
		m = m or mw.ustring.match(remainder, &amp;quot;^&amp;quot; .. vowel)&lt;br /&gt;
		&lt;br /&gt;
		if m then&lt;br /&gt;
			-- Found a vowel, add it&lt;br /&gt;
			count = count + 1&lt;br /&gt;
			remainder = string.sub(remainder, #m + 1)&lt;br /&gt;
		else&lt;br /&gt;
			-- Found a non-vowel, skip it&lt;br /&gt;
			remainder = string.gsub(remainder, &amp;quot;^&amp;quot; .. UTF8Char, &amp;quot;&amp;quot;)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if count ~= 0 then return count end&lt;br /&gt;
	&lt;br /&gt;
	return nil&lt;br /&gt;
	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function export.countVowels2Test(frame)&lt;br /&gt;
	local params = {&lt;br /&gt;
		[1] = {required = true},&lt;br /&gt;
		[2] = {default = &amp;quot;&amp;quot;},&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	local args = require(&amp;quot;Module:parameters&amp;quot;).process(frame.args, params)&lt;br /&gt;
	&lt;br /&gt;
	local lang = require(&amp;quot;Module:languages&amp;quot;).getByCode(args[1]) or require(&amp;quot;Module:languages&amp;quot;).err(args[1], 1)&lt;br /&gt;
	&lt;br /&gt;
	local count = export.getVowels(args[2], lang)&lt;br /&gt;
	&lt;br /&gt;
	return 'The text &amp;quot;' .. args[2] .. '&amp;quot; contains ' .. count .. ' vowels.'&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local function countVowels(text)&lt;br /&gt;
	text = mw.ustring.toNFD(text) or error(&amp;quot;Invalid UTF-8&amp;quot;)&lt;br /&gt;
	&lt;br /&gt;
	local _, count = mw.ustring.gsub(text, vowel, &amp;quot;&amp;quot;)&lt;br /&gt;
	local _, sequenceCount = mw.ustring.gsub(text, vowel..&amp;quot;+&amp;quot;, &amp;quot;&amp;quot;)&lt;br /&gt;
	local _, nonsyllabicCount = mw.ustring.gsub(text, vowel .. nonsyllabicDiacritic, &amp;quot;&amp;quot;)&lt;br /&gt;
	local _, tieCount = mw.ustring.gsub(text, vowel .. tie .. vowel, &amp;quot;&amp;quot;)&lt;br /&gt;
	&lt;br /&gt;
	local diphthongCount = count - (nonsyllabicCount + tieCount)&lt;br /&gt;
	&lt;br /&gt;
	return count, sequenceCount, diphthongCount&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local function countDiphthongs(text, lang)&lt;br /&gt;
	text = mw.ustring.toNFD(text) or error(&amp;quot;Invalid UTF-8&amp;quot;)&lt;br /&gt;
	&lt;br /&gt;
	local diphthongs = diphthongs[lang:getCode()] or {}&lt;br /&gt;
	&lt;br /&gt;
	local _, count&lt;br /&gt;
	local total = 0&lt;br /&gt;
	&lt;br /&gt;
	if diphthongs then&lt;br /&gt;
		for i, diphthong in pairs(diphthongs) do&lt;br /&gt;
			_, count = mw.ustring.gsub(text, diphthong, &amp;quot;&amp;quot;)&lt;br /&gt;
			total = total + count&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return total&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function export.countVowels(frame)&lt;br /&gt;
	local params = {&lt;br /&gt;
		[1] = {default = &amp;quot;&amp;quot;},&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	local args = require(&amp;quot;Module:parameters&amp;quot;).process(frame.args, params)&lt;br /&gt;
	&lt;br /&gt;
	local count, sequenceCount, diphthongCount = countVowels(args[1])&lt;br /&gt;
	&lt;br /&gt;
	local outputs = {}&lt;br /&gt;
	table.insert(outputs, (count or 'an unknown number of') .. ' vowels')&lt;br /&gt;
	table.insert(outputs, (sequenceCount or 'an unknown number of') .. ' vowel sequences')&lt;br /&gt;
	table.insert(outputs, (diphthongCount or 'an unknown number of') .. ' vowels or vowels and diphthongs')&lt;br /&gt;
	&lt;br /&gt;
	return 'The text &amp;quot;' .. args[1] .. '&amp;quot; contains ' .. mw.text.listToText(outputs) .. &amp;quot;.&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function export.countVowelsDiphthongs(frame)&lt;br /&gt;
	local params = {&lt;br /&gt;
		[1] = {required = true},&lt;br /&gt;
		[2] = {default = &amp;quot;&amp;quot;},&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	local args = require(&amp;quot;Module:parameters&amp;quot;).process(frame.args, params)&lt;br /&gt;
	&lt;br /&gt;
	local lang = require(&amp;quot;Module:languages&amp;quot;).getByCode(args[1]) or require(&amp;quot;Module:languages&amp;quot;).err(args[1], 1)&lt;br /&gt;
	&lt;br /&gt;
	local vowels = countVowels(args[2])&lt;br /&gt;
	local count = vowels - countDiphthongs(args[2], lang) or 0&lt;br /&gt;
	&lt;br /&gt;
	local out = 'The text &amp;quot;' .. args[2] .. '&amp;quot; contains ' .. (count or 'an unknown number of')&lt;br /&gt;
	&lt;br /&gt;
	if count == 1 then&lt;br /&gt;
		out = out .. ' vowel or diphthong.'&lt;br /&gt;
	else&lt;br /&gt;
		out = out .. ' vowels or diphthongs.'&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return out&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return export&lt;/div&gt;</summary>
		<author><name>Jācōbus</name></author>
	</entry>
</feed>