Module:grc-pronunciation: difference between revisions

From Wiktionary, the free dictionary
Jump to navigation Jump to search
Content deleted Content added
Undo revision 41148855 by Erutuon (talk): then again, something in the module is making clusters like σμ be transcribed with /z/ when it should be /s/...
to make the "more" button not be on the far right side of the content area: turned off text wrapping, set width of the containing div to max-content, and put the "more" button in a div to the right of another div containing the two transcriptions
Line 559: Line 559:
--Final format
--Final format
local inlineProns = '<div class="vsShow" style="display:none">\n* IPA: '
local inlineProns = '<div class="vsShow" style="display: none;">\n* IPA: '
for i=1, #inlinePeriods do
for i=1, #inlinePeriods do
period = inlinePeriods[i]
period = inlinePeriods[i]
Line 581: Line 581:
end
end
fullProns = fullProns..'</div>'
fullProns = fullProns..'</div>'
local final = '<div class="vsSwitcher vsToggleCategory-pronunciations"><span class="vsToggleElement" style="float:right">&nbsp;</span>'..inlineProns..fullProns..'</div>'
local final = '<div class="vsSwitcher vsToggleCategory-pronunciations" style="white-space: nowrap; width: max-content;"><div style="float: right;"><span class="vsToggleElement" style="float: right;">&nbsp;</span></div><div style="float: right;">'..inlineProns..fullProns..'</div></div>'
return final
return final
end
end

Revision as of 04:24, 19 October 2016

This module generates pronunciations for {{grc-IPA}}, which is used in Ancient Greek entries.

Use the sandbox module to try things out without causing problems in entries.

The biggest part of the data is contained in the data module.

Testcases

Module error: The function "example" does not exist.


local export = {}

local m_accent = require('Module:grc-accent')

local periods = {'cla', 'koi1', 'koi2', 'byz1', 'byz2'}
local inlinePeriods = {'cla', 'koi2', 'byz2'}
local IPAs = {}

local periodLabels = {['cla']='[[w:Ancient Greek phonology|5th BC Attic]]',
	['koi1'] = '[[w:Koine Greek phonology|1st BC Egyptian]]',
	['koi2'] = '[[w:Koine Greek phonology|4th AD Koine]]',
	['byz1'] = '[[w:Medieval Greek|10th AD Byzantine]]',
	['byz2'] = '[[w:Medieval Greek|15th AD Constantinopolitan]]',
	}

--Combining diacritics are tricky.
local d1 = '͜'   --Tie bar    
local d2 = '́'  --High pitch
local d3 = '̀'  --Low pitch
local d4 = '᷄'  --Mid/High pitch
local d5 = '᷆'  --Mid/Low pitch
local d6 = '᷇'  --High/Mid pitch
local d7 = '̆'  --Short vowel length

local l = {
	[''] = {['end']=true},
	[' '] = {['p'] = {['cla'] = ' '}},
	['β'] = {['type'] = 'consonant', ['stop'] = true, ['voiced']=true, ['clusters']={['δ']=true, ['λ']=true, ['ρ']=true}, 
		['p'] = {['cla']='b', ['koi1']='b', ['koi2']='β', ['byz1']='v', ['byz2']={{'1=β', ''}, {'-1=μ', 'b'}, 'v'}}},
	['γ'] = {['type'] = 'consonant', ['dorsal'] = true, ['stop'] = true, ['voiced']=true, ['clusters']={['λ']=true, ['ν']=true, ['ρ']=true}, 
		['p'] = {['cla']={{'1.dorsal', 'ŋ'}, 'ɡ'}, ['koi1']={{'1.dorsal', 'ŋ'}, 'ɡ'}, 
			['koi2']={{'1.dorsal', 'ŋ'}, 'ɣ'}, 
			['byz1']={{'1.dorsal', {{'1-preFront', 'ɲ'}, 'ŋ'}}, {'0-preFront', {{'-1=γ', 'ɟ'}, 'ʝ'}}, 'ɣ'},
			['byz2']={{'1.dorsal', {{'1-preFront', 'ɲ'}, 'ŋ'}}, {'0-preFront', {{'-1=γ', 'ɟ'}, 'ʝ'}}, 'ɣ'}}},
	['δ'] = {['type'] = 'consonant', ['stop']=true, ['voiced']=true, ['clusters']={['ρ']=true}, 
		['p'] = {['cla']='d', ['koi1']='d', ['koi2']='ð', ['byz1']='ð', ['byz2']={{'1=δ', ''}, {'-1=ν', 'd'}, 'ð'}}},
	['ζ'] = {['type'] = 'consonant', ['voiced']=true, ['clusters']={}, 
		['p'] = {['cla']='zd', ['koi1']='z', ['koi2']='z', ['byz1']='z', ['byz2']='z'}},
	['θ'] = {['type'] = 'consonant', ['stop']=true, ['unvoiced']=true, ['clusters']={['ρ']=true}, 
		['p'] = {['cla']='tʰ', ['koi1']='tʰ', ['koi2']='θ', ['byz1']='θ', ['byz2']={{'1=θ', ''}, 'θ'}}},
	['κ'] = {['type'] = 'consonant', ['dorsal'] = true, ['stop']=true, ['unvoiced']=true, ['clusters']={['λ']=true, ['ν']=true, ['τ']=true, ['ρ']=true}, 
		['p'] = {['cla']={{'1.voiced+1.stop', 'ɡ'}, 'k'}, 
			['koi1']={{'1.voiced+1.stop', 'ɡ'}, 'k'}, 
			['koi2']={{'1.voiced+1.stop', 'ɡ'}, 'k'}, 
			['byz1']={{'1=κ', ''}, {'1.voiced+1.stop', 'ɡ'}, {'0-preFront', 'c'}, 'k'},
			['byz2']={{'1=κ', ''}, {'1.voiced+1.stop', 'ɡ'}, {'0-preFront', 'c'}, 'k'}}},
	['λ'] = {['type'] = 'consonant', ['voiced']=true, ['clusters']={}, 
		['p'] = {['cla']='l', ['koi1']='l', ['koi2']='l', ['byz1']='l', ['byz2']={{'1=λ', ''}, 'l'}}},
	['μ'] = {['type'] = 'consonant', ['voiced']=true, ['clusters']={['ν']=true}, 
		['p'] = {['cla']='m', ['koi1']='m', ['koi2']='m', ['byz1']='m', ['byz2']={{'1=μ/1=β', ''}, 'm'}}},
	['ν'] = {['type'] = 'consonant', ['voiced']=true, ['clusters']={}, 
		['p'] = {['cla']='n', ['koi1']='n', ['koi2']='n', ['byz1']='n', ['byz2']={{'1=ν/1=δ', ''}, 'n'}}},
	['ξ'] = {['type'] = 'consonant', ['dorsal'] = true, ['stop']=true, ['unvoiced']=true, ['clusters']={}, 
		['p'] = {['cla']='kʰs', ['koi1']='kʰs', ['koi2']='xs', ['byz1']='ks', ['byz2']='ks'}},
	['π'] = {['type'] = 'consonant', ['stop']=true, ['unvoiced']=true, ['clusters']={['λ']=true, ['ν']=true, ['ρ']=true, ['τ']=true}, 
		['p'] = {['cla']='p', ['koi1']='p', ['koi2']='p', ['byz1']='p', ['byz2']={{'1=π', ''}, 'p'}}},
	['ρ'] = {['type'] = 'consonant', ['voiced']=true, ['clusters']={}, 
		['p'] = {['cla']={{'1=ρ/1=ῥ/-1=ρ', 'r̥'}, 'r'}, ['koi1']={{'1=ρ/1=ῥ/-1=ρ', 'r̥'}, 'r'}, ['koi2']='r', ['byz1']='r', ['byz2']={{'1=ρ', ''}, 'r'}}},
	['ῥ'] = {['type'] = 'consonant', ['voiced']=false, ['clusters']={}, 
		['p'] = {['cla']='r̥', ['koi1']='r̥', ['koi2']='r', ['byz1']='r', ['byz2']={{'1=ρ', ''}, 'r'}}},
	['σ'] = {['type'] = 'consonant', ['unvoiced']=true, ['clusters']={['β']=true, ['θ']=true, ['κ']=true, ['μ']=true, ['π']=true, ['τ']=true, ['φ']=true, ['χ']=true, }, 
		['p'] = {['cla']='s', ['koi1']='s', ['koi2']='s', ['byz1']='s', ['byz2']={{'1=σ', ''}, 's'}}},
	['τ'] = {['type'] = 'consonant', ['stop']=true, ['unvoiced']=true, ['clusters']={['λ']=true, ['μ']=true, ['ρ']=true}, 
		['p'] = {['cla']='t', ['koi1']='t', ['koi2']='t', ['byz1']='t', ['byz2']={{'1=τ', ''}, 't'}}},
	['φ'] = {['type'] = 'consonant', ['stop']=true, ['unvoiced']=true, ['clusters']={['θ']=true, ['λ']=true, ['ρ']=true}, 
		['p'] = {['cla']='pʰ', ['koi1']='pʰ', ['koi2']='ɸ', ['byz1']='f', ['byz2']={{'1=φ', ''}, 'f'}}},
	['χ'] = {['type'] = 'consonant', ['dorsal']=true, ['stop']=true, ['unvoiced']=true, ['clusters']={['θ']=true, ['λ']=true, ['ρ']=true}, 
		['p'] = {['cla']='kʰ', ['koi1']='kʰ', ['koi2']='x', 
			['byz1']={{'1=χ', ''}, {'0-preFront', 'ç'}, 'x'},
			['byz2']={{'1=χ', ''}, {'0-preFront', 'ç'}, 'x'}}},
	['ψ'] = {['type'] = 'consonant', ['stop']=true, ['unvoiced']=true, ['clusters']={}, 
		['p'] = {['cla']='pʰs', ['koi1']='pʰs', ['koi2']='ɸs', ['byz1']='ps', ['byz2']='ps'}},
	['ϝ'] = {['type'] = 'consonant', ['voiced']=true, ['clusters']={},
		['p'] = {['cla']='w', ['koi1']='', ['koi2']='', ['byz1']='', ['byz2']=''}},
	['α'] = {['type'] = 'vowel', ['length']='either', 
		['p'] = {['cla']='a', ['koi1']='a', ['koi2']='a', ['byz1']='a', ['byz2']='a'}},
	['ε'] = {['type'] = 'vowel', ['length']='short', 
		['p'] = {['cla']='e', ['koi1']='ɛ', ['koi2']='e', ['byz1']='e', ['byz2']='e'}},
	['η'] = {['type'] = 'vowel', ['length']='long', 
		['p'] = {['cla']='ɛ', ['koi1']='e', ['koi2']='i', ['byz1']='i', ['byz2']='i'}},
	['ι'] = {['type'] = 'vowel', ['length']='either', 
		['p'] = {['cla']='i', ['koi1']='i', ['koi2']='i', ['byz1']='i', ['byz2']='i'}},
	['ο'] = {['type'] = 'vowel', ['length']='short', 
		['p'] = {['cla']='o', ['koi1']='o', ['koi2']='o', ['byz1']='o', ['byz2']='o'}},
	['υ'] = {['type'] = 'vowel', ['length']='either', 
		['p'] = {['cla']='y', ['koi1']='y', ['koi2']='y', ['byz1']='y', ['byz2']='i'}},
	['ω'] = {['type'] = 'vowel', ['length']='long', 
		['p'] = {['cla']='ɔ', ['koi1']='o', ['koi2']='o', ['byz1']='o', ['byz2']='o'}},
	['ϊ'] = {['type'] = 'vowel', ['diar']=true},
	['ϋ'] = {['type'] = 'vowel', ['diar']=true},
	['ἀ'] = {['type'] = 'vowel', ['breath']='smooth'},	
	['ἐ'] = {['type'] = 'vowel', ['breath']='smooth'},	
	['ἠ'] = {['type'] = 'vowel', ['breath']='smooth'},
	['ἰ'] = {['type'] = 'vowel', ['breath']='smooth'},	
	['ὀ'] = {['type'] = 'vowel', ['breath']='smooth'},
	['ὐ'] = {['type'] = 'vowel', ['breath']='smooth'},
	['ὠ'] = {['type'] = 'vowel', ['breath']='smooth'},
	['ὰ'] = {['type'] = 'vowel', ['accent']='grave'},
	['ᾀ'] = {['type'] = 'vowel', ['breath']='smooth', ['subi']=true},
	['ᾐ'] = {['type'] = 'vowel', ['breath']='smooth', ['subi']=true},
	['ᾠ'] = {['type'] = 'vowel', ['breath']='smooth', ['subi']=true},
	['ᾰ'] = {['type'] = 'vowel', ['length']='short'},
	['ῐ'] = {['type'] = 'vowel', ['length']='short'},
	['ῠ'] = {['type'] = 'vowel', ['length']='short'},
	['ἁ'] = {['type'] = 'vowel', ['breath']='rough'},
	['ἑ'] = {['type'] = 'vowel', ['breath']='rough'},
	['ἡ'] = {['type'] = 'vowel', ['breath']='rough'},
	['ἱ'] = {['type'] = 'vowel', ['breath']='rough'},
	['ὁ'] = {['type'] = 'vowel', ['breath']='rough'},
	['ὑ'] = {['type'] = 'vowel', ['breath']='rough'},
	['ὡ'] = {['type'] = 'vowel', ['breath']='rough'},	
	['ά'] = {['type'] = 'vowel', ['accent']='acute'},	
	['ᾁ'] = {['type'] = 'vowel', ['breath']='rough', ['subi']=true},
	['ᾑ'] = {['type'] = 'vowel', ['breath']='rough', ['subi']=true},
	['ᾡ'] = {['type'] = 'vowel', ['breath']='rough', ['subi']=true},	
	['ᾱ'] = {['type'] = 'vowel', ['length']='long'},
	['ῑ'] = {['type'] = 'vowel', ['length']='long'},
	['ῡ'] = {['type'] = 'vowel', ['length']='long'},
	['ἂ'] = {['type'] = 'vowel', ['breath']='smooth', ['accent']='grave'},
	['ἒ'] = {['type'] = 'vowel', ['breath']='smooth', ['accent']='grave'},
	['ἢ'] = {['type'] = 'vowel', ['breath']='smooth', ['accent']='grave'},
	['ἲ'] = {['type'] = 'vowel', ['breath']='smooth', ['accent']='grave'},
	['ὂ'] = {['type'] = 'vowel', ['breath']='smooth', ['accent']='grave'},
	['ὒ'] = {['type'] = 'vowel', ['breath']='smooth', ['accent']='grave'},
	['ὢ'] = {['type'] = 'vowel', ['breath']='smooth', ['accent']='grave'},
	['ὲ'] = {['type'] = 'vowel', ['accent']='grave'},
	['ᾂ'] = {['type'] = 'vowel', ['breath']='smooth', ['accent']='grave', ['subi']=true},
	['ᾒ'] = {['type'] = 'vowel', ['breath']='smooth', ['accent']='grave', ['subi']=true},
	['ᾢ'] = {['type'] = 'vowel', ['breath']='smooth', ['accent']='grave', ['subi']=true},
	['ᾲ'] = {['type'] = 'vowel', ['accent']='grave', ['subi']=true},
	['ῂ'] = {['type'] = 'vowel', ['accent']='grave', ['subi']=true},
	['ῒ'] = {['type'] = 'vowel', ['accent']='grave', ['diar']=true},
	['ῢ'] = {['type'] = 'vowel', ['accent']='grave', ['diar']=true},
	['ῲ'] = {['type'] = 'vowel', ['accent']='grave', ['subi']=true},
	['ἃ'] = {['type'] = 'vowel', ['accent']='grave', ['breath']='rough'},
	['ἓ'] = {['type'] = 'vowel', ['accent']='grave', ['breath']='rough'},
	['ἣ'] = {['type'] = 'vowel', ['accent']='grave', ['breath']='rough'},
	['ἳ'] = {['type'] = 'vowel', ['accent']='grave', ['breath']='rough'},
	['ὃ'] = {['type'] = 'vowel', ['accent']='grave', ['breath']='rough'},
	['ὓ'] = {['type'] = 'vowel', ['accent']='grave', ['breath']='rough'},
	['ὣ'] = {['type'] = 'vowel', ['accent']='grave', ['breath']='rough'},
	['έ'] = {['type'] = 'vowel', ['accent']='acute'},
	['ᾃ'] = {['type'] = 'vowel', ['accent']='grave', ['breath']='rough', ['subi']=true},
	['ᾓ'] = {['type'] = 'vowel', ['accent']='grave', ['breath']='rough', ['subi']=true},
	['ᾣ'] = {['type'] = 'vowel', ['accent']='grave', ['breath']='rough', ['subi']=true},
	['ᾳ'] = {['type'] = 'vowel', ['subi']=true},
	['ῃ'] = {['type'] = 'vowel', ['subi']=true},
	['ΐ'] = {['type'] = 'vowel', ['accent']='acute', ['diar']=true},
	['ΰ'] = {['type'] = 'vowel', ['accent']='acute', ['diar']=true},
	['ῳ'] = {['type'] = 'vowel', ['subi']=true},
	['ἄ'] = {['type'] = 'vowel', ['accent']='acute', ['breath']='smooth'},
	['ἔ'] = {['type'] = 'vowel', ['accent']='acute', ['breath']='smooth'},
	['ἤ'] = {['type'] = 'vowel', ['accent']='acute', ['breath']='smooth'},
	['ἴ'] = {['type'] = 'vowel', ['accent']='acute', ['breath']='smooth'},
	['ὄ'] = {['type'] = 'vowel', ['accent']='acute', ['breath']='smooth'},
	['ὔ'] = {['type'] = 'vowel', ['accent']='acute', ['breath']='smooth'},
	['ὤ'] = {['type'] = 'vowel', ['accent']='acute', ['breath']='smooth'},
	['ὴ'] = {['type'] = 'vowel', ['accent']='grave'},
	['ᾄ'] = {['type'] = 'vowel', ['accent']='acute', ['breath']='smooth', ['subi']=true},
	['ᾔ'] = {['type'] = 'vowel', ['accent']='acute', ['breath']='smooth', ['subi']=true},
	['ᾤ'] = {['type'] = 'vowel', ['accent']='acute', ['breath']='smooth', ['subi']=true},
	['ᾴ'] = {['type'] = 'vowel', ['accent']='acute', ['subi']=true},
	['ῄ'] = {['type'] = 'vowel', ['accent']='acute', ['subi']=true},
	['ῴ'] = {['type'] = 'vowel', ['accent']='acute', ['subi']=true},
	['ἅ'] = {['type'] = 'vowel', ['accent']='acute', ['breath']='rough'},
	['ἕ'] = {['type'] = 'vowel', ['accent']='acute', ['breath']='rough'},
	['ἥ'] = {['type'] = 'vowel', ['accent']='acute', ['breath']='rough'},
	['ἵ'] = {['type'] = 'vowel', ['accent']='acute', ['breath']='rough'},
	['ὅ'] = {['type'] = 'vowel', ['accent']='acute', ['breath']='rough'},
	['ὕ'] = {['type'] = 'vowel', ['accent']='acute', ['breath']='rough'},
	['ὥ'] = {['type'] = 'vowel', ['accent']='acute', ['breath']='rough'},
	['ή'] = {['type'] = 'vowel', ['accent']='acute'},	
	['ᾅ'] = {['type'] = 'vowel', ['accent']='acute', ['breath']='rough', ['subi']=true},
	['ᾕ'] = {['type'] = 'vowel', ['accent']='acute', ['breath']='rough', ['subi']=true},
	['ᾥ'] = {['type'] = 'vowel', ['accent']='acute', ['breath']='rough', ['subi']=true},
	['ἆ'] = {['type'] = 'vowel', ['accent']='circum', ['breath']='smooth'},
	['ἦ'] = {['type'] = 'vowel', ['accent']='circum', ['breath']='smooth'},
	['ἶ'] = {['type'] = 'vowel', ['accent']='circum', ['breath']='smooth'},
	['ὖ'] = {['type'] = 'vowel', ['accent']='circum', ['breath']='smooth'},	
	['ὦ'] = {['type'] = 'vowel', ['accent']='circum', ['breath']='smooth'},
	['ὶ'] = {['type'] = 'vowel', ['accent']='grave'},
	['ᾆ'] = {['type'] = 'vowel', ['accent']='circum', ['breath']='smooth', ['subi']=true},
	['ᾖ'] = {['type'] = 'vowel', ['accent']='circum', ['breath']='smooth', ['subi']=true},
	['ᾦ'] = {['type'] = 'vowel', ['accent']='circum', ['breath']='smooth', ['subi']=true},
	['ᾶ'] = {['type'] = 'vowel', ['accent']='circum'},
	['ῆ'] = {['type'] = 'vowel', ['accent']='circum'},
	['ῖ'] = {['type'] = 'vowel', ['accent']='circum'},	
	['ῦ'] = {['type'] = 'vowel', ['accent']='circum'},
	['ῶ'] = {['type'] = 'vowel', ['accent']='circum'},
	['ἇ'] = {['type'] = 'vowel', ['accent']='circum', ['breath']='rough'},
	['ἧ'] = {['type'] = 'vowel', ['accent']='circum', ['breath']='rough'},
	['ἷ'] = {['type'] = 'vowel', ['accent']='circum', ['breath']='rough'},
	['ὗ'] = {['type'] = 'vowel', ['accent']='circum', ['breath']='rough'},
	['ὧ'] = {['type'] = 'vowel', ['accent']='circum', ['breath']='rough'},
	['ί'] = {['type'] = 'vowel', ['accent']='acute'},	
	['ᾇ'] = {['type'] = 'vowel', ['accent']='circum', ['breath']='rough', ['subi']=true},
	['ᾗ'] = {['type'] = 'vowel', ['accent']='circum', ['breath']='rough', ['subi']=true},
	['ᾧ'] = {['type'] = 'vowel', ['accent']='circum', ['breath']='rough', ['subi']=true},
	['ᾷ'] = {['type'] = 'vowel', ['accent']='circum', ['subi']=true},
	['ῇ'] = {['type'] = 'vowel', ['accent']='circum', ['subi']=true},
	['ῗ'] = {['type'] = 'vowel', ['accent']='circum', ['diar']=true},
	['ῧ'] = {['type'] = 'vowel', ['accent']='circum', ['diar']=true},
	['ῷ'] = {['type'] = 'vowel', ['accent']='circum', ['subi']=true},
	['ὸ'] = {['type'] = 'vowel', ['accent']='grave'},
	['ό'] = {['type'] = 'vowel', ['accent']='acute'},
	['ὺ'] = {['type'] = 'vowel', ['accent']='grave'},
	['ύ'] = {['type'] = 'vowel', ['accent']='acute'},
	['ὼ'] = {['type'] = 'vowel', ['accent']='grave'},
	['ώ'] = {['type'] = 'vowel', ['accent']='acute'},
	['αι'] = {['p'] = {['cla'] = {{'1.end', 'a'..d1..'i'}, 'a'..d1..'i'}, ['koi1']='ɛ', ['koi2']='ɛ', ['byz1']='e', ['byz2']='e'}},
	['ει'] = {['p'] = {['cla'] = 'e', ['koi1']='i', ['koi2']='i', ['byz1']='i', ['byz2']='i'}},
	['οι'] = {['p'] = {['cla'] = {{'1.end', 'o'..d1..'i'}, 'o'..d1..'i'}, ['koi1']='y', ['koi2']='y', ['byz1']='y', ['byz2']='i'}},
	['υι'] = {['p'] = {['cla'] = 'y', ['koi1']='y', ['koi2']='y', ['byz1']='y', ['byz2']='i'}},
	['αυ'] = {['p'] = {['cla'] = 'a'..d1..'u', ['koi1']={{'1.unvoiced', 'aʍ'}, 'aw'}, 
		['koi2']={{'1.unvoiced', 'aɸ'}, 'aβ'}, ['byz1']={{'1.unvoiced', 'af'}, 'av'}, 
		['byz2']={{'1.unvoiced', 'af'}, 'av'}}},
	['ευ'] = {['p'] = {['cla'] = 'e'..d1..'u', ['koi1']={{'1.unvoiced', 'eʍ'}, 'ew'}, 
		['koi2']={{'1.unvoiced', 'eɸ'}, 'eβ'}, ['byz1']={{'1.unvoiced', 'ef'}, 'ev'}, 
		['byz2']={{'1.unvoiced', 'ef'}, 'ev'}}},
	['ου'] = {['p'] = {['cla'] = 'o', ['koi1']='u', ['koi2']='u', ['byz1']='u', ['byz2']='u'}},
	}

local uStart = {['α'] = true, ['ε'] = true, ['ο'] = true}
local iStart = {['α'] = true, ['ε'] = true, ['ο'] = true, ['υ'] = true}

local iCons = {['b']=true, ['ɡ']=true, ['ŋ']=true, ['d']=true, ['z']=true, 
	['k']=true, ['l']=true, ['m']=true, ['n']=true, ['p']=true, ['r']=true, 
	['s']=true, ['t']=true, ['β']=true, ['ð']=true, ['ɣ']=true, ['ɸ']=true, 
	['θ']=true, ['x']=true, ['f']=true, ['v']=true, ['ɟ']=true, ['ʝ']=true, 
	['c']=true, ['ç']=true}

local iVows = {['a']=true, ['e']=true, ['i']=true, ['o']=true, ['u']=true, 
	['y']=true, ['w']=true, ['j']=true, ['ɛ']=true, ['ɔ']=true}

local iDias = {[d2]=true, [d3]=true, [d4]=true, [d5]=true, [d6]=true, [d7]=true,
	['ʰ']=true, ['ː']=true, ['̥']=true}

local iLiqs = {['r']=true, ['l']=true, ['n']=true}

local iStops = {['b']=true, ['ɡ']=true, ['d']=true, ['k']=true, ['p']=true, 
	['t']=true, ['β']=true, ['ð']=true, ['ɣ']=true, ['ɸ']=true, ['θ']=true, 
	['x']=true, ['f']=true}


function export.create(frame)
	local args = frame:getParent().args
	local title = args['w'] or args[1] or mw.title.getCurrentTitle().text
	title = mw.ustring.lower(title)
	title = mw.ustring.gsub(title, 'ς', 'σ')
	title = mw.ustring.gsub(title, 'ῤ', 'ρ')
	for i=1, #periods do
		IPAs[periods[i]] = {['notes']={}}
	end
	local length = mw.ustring.len(title)
	local x = 1
	local letter = ''
	local nextLetter = ''
	local cla = {}
	local alert = false
	local naked = ''
	local accent = ''
	local diphthong = false
	--local clusters = {}
	--local cluster = ''
	local function preFront(which)
		local fronts = {['ι']=true, ['η']=true, ['ε']=true, ['υ']=true, ['αι']=true, ['οι']=true}
		local let1 = mw.ustring.sub(title, x+1+which, x+1+which)
		local let2 = mw.ustring.sub(title, x+2+which, x+2+which)
		return fronts[m_accent.strip_accent(let1)] or (fronts[m_accent.strip_accent(let1..let2)] and not mw.ustring.match(let2,'[ϊΐῒῗ]'))
	end

	local function decode(condition)
		if mw.ustring.find(condition, '[+/]') then  --"If" and "and" statements.
			--Note that we're finding the last operator first, 
			--which means that the first will get ultimately get decided first.
			--It's a recursive function.
			local sep = mw.ustring.find(condition, "[/+][^/+]*$")  
			local chunk1 = mw.ustring.sub(condition, 1, sep - 1)
			local chunk2 = mw.ustring.sub(condition, sep + 1)
			if mw.ustring.sub(condition, sep, sep) == '/' then
				return decode(chunk1) or decode(chunk2)
			elseif mw.ustring.sub(condition, sep, sep) == '+' then
				return decode(chunk1) and decode(chunk2)
			end
		elseif mw.ustring.find(condition, '=') then
			local sep = mw.ustring.find(condition, '=')  
			local chunk1 = mw.ustring.sub(condition, 1, sep - 1)
			local chunk2 = mw.ustring.sub(condition, sep + 1)
			local checkLetter
			if tonumber(x+chunk1) < 1 then
				checkLetter = ''
			else 
				checkLetter = mw.ustring.sub(title, x+chunk1, x+chunk1)
			end
			return checkLetter == chunk2
		elseif mw.ustring.find(condition, '%.') then
			local sep = mw.ustring.find(condition, '%.')  
			local chunk1 = mw.ustring.sub(condition, 1, sep - 1)
			local chunk2 = mw.ustring.sub(condition, sep + 1)
			local checkLetter = mw.ustring.sub(title, x+chunk1, x+chunk1)
			return l[checkLetter][chunk2]
		elseif mw.ustring.find(condition, '%-') then
			local sep = mw.ustring.find(condition, '%-')
			local chunk1 = mw.ustring.sub(condition, 1, sep - 1)
			local chunk2 = mw.ustring.sub(condition, sep + 1)
			if chunk2 == 'preFront' then
				return preFront(chunk1)
			end
		end
				
	end
	local function check(p, period)
		if type(p) == 'string' then
			return p
		elseif type(p) == 'table' then   --This table is sequential, with a variable number of entries.
			for i = 1, #p do
				possP = p[i]
				if type(possP) == 'string' then
					return possP
				elseif type(possP) == 'table' then    --This table is paired, with two values: a condition and a result.
					rawCondition = possP[1]
					rawResult = possP[2]
					local condition = decode(rawCondition)
					if condition then
						if type(rawResult) == 'string' then
							return rawResult
						else
							return check(rawResult, period)
						end
					end	
				end
			end
		end
	end
	while x <= length do
		letter = mw.ustring.sub(title, x, x)
		nextLetter = mw.ustring.sub(title, x+1, x+1)
		if not l[letter] then
			
		elseif l[letter].type == 'consonant' then
			for i = 1, #periods do
				period = periods[i]
				currentP = l[letter].p[period]
				result = check(currentP, period)
				table.insert(IPAs[period], result)
			end
		
		elseif l[letter].type == 'vowel' then
		
			--Start with a diphthong check
			local diphthong = false
			local vCurrent, vForm, vLength;
			if iStart[letter] and (l[nextLetter] and l[nextLetter].type == 'vowel' and (nextLetter == 'ι' or (m_accent.strip_accent(nextLetter) == 'ι' and not l[nextLetter].diar))) then
				diphthong = letter..'ι'
			elseif uStart[letter] and (l[nextLetter] and l[nextLetter].type == 'vowel' and (nextLetter == 'υ' or (m_accent.strip_accent(nextLetter) == 'υ' and not l[nextLetter].diar))) then
				diphthong = letter..'υ'
			end
			
			if diphthong then
				vCurrent = nextLetter
				vForm = diphthong
				vLength = 'long'
				x = x + 1
				nextLetter = mw.ustring.sub(title, x+1, x+1)
			else 
				vCurrent = letter
				vForm = m_accent.strip_accent(letter)
				vLength = l[vCurrent].length or l[vForm].length
			end
			for i = 1, #periods do
				period = periods[i]
				if period == 'cla' then
					if l[vCurrent].breath == 'rough' then
						table.insert(IPAs['cla'], 'h')
					end
				elseif period == 'koi1' then
					if l[vCurrent].breath == 'rough' then
						table.insert(IPAs['koi1'], '(h)')
					end
				end
				if period ~= 'cla' then
					--All other periods have a stress accent, instead of Classical's tonal accent.
					--The stress diacritic is initially placed immediately preceding the vowel,
					--and is moved to the front of the syllable during syllabification.
					if l[vCurrent].accent then
						table.insert(IPAs[period], 'ˈ')
					end
					local vIP = check(l[vForm].p[period], period)
					table.insert(IPAs[period], vIP)
					
				else
					--Classical vowels are hard.
					if vLength == 'either' then
						if l[vCurrent].accent == 'circum' then
							vLength = 'long'
						elseif l[vCurrent].subi then
							vLength = 'long'
						elseif nextLetter == '̄' or nextLetter == '¯' then
							vLength = 'long'
						elseif nextLetter == '̆' or nextLetter == '˘' then
							vLength = 'short'
						else
							table.insert(IPAs.cla.notes, 'ambiguous vowel '..vCurrent..' at '..x)
						end
					end
					
					local vIP = check(l[vForm].p.cla, cla)  --vIP stands for initial pronunciation
					
					--There has to be a prettier way to do this, but I just can't think of it.
					if mw.ustring.len(vIP) > 1 then  --i.e. if it's a phonetic dipthong
						if l[vCurrent].accent == 'acute' then
							vFP = vIP..d2
						elseif l[vCurrent].accent == 'grave' then
							vFP = vIP..d3
						elseif l[vCurrent].accent == 'circum' then
							vFP = mw.ustring.sub(vIP, 1, 1)..d2..mw.ustring.sub(vIP, 2)
						else
							vFP = vIP
						end
					elseif l[vCurrent].subi then
						if l[vCurrent].accent == 'acute' then
							vFP = vIP..d1..'ːj'..d2
						elseif l[vCurrent].accent == 'grave' then
							vFP = vIP..d1..'ːj'..d3
						elseif l[vCurrent].accent == 'circum' then
							vFP = vIP..d2..d1..'ːj'
						else
							vFP = vIP..d1..'ːj'
						end
					elseif vLength == 'long' then
						if l[vCurrent].accent == 'acute' then
							vFP = vIP..d4..'ː'
						elseif l[vCurrent].accent == 'grave' then
							vFP = vIP..d5..'ː'
						elseif l[vCurrent].accent == 'circum' then
							vFP = vIP..d6..'ː'
						else
							vFP = vIP..'ː'
						end
					else
						if l[vCurrent].accent == 'acute' then
							vFP = vIP..d2
						elseif l[vCurrent].accent == 'grave' then
							vFP = vIP..d3
						else
							vFP = vIP
						end
					end
					table.insert(IPAs['cla'], vFP)
	
				end
			end
		else
			alert = true
		end
		x = x + 1
	end
	
	--Concatenate the IPAs
	for i=1, #periods do
		IPAs[periods[i]] = {['IPA']=table.concat(IPAs[periods[i]], ''), ['notes']=IPAs[periods[i]]['notes']}
	end
	
	--Syllabify
	for i=1, #periods do
		local period = periods[i]
		local word = IPAs[period].IPA
		local syllables = {}
		local cVowel, nVowel, sBreak, stress, wordEnd, searching
		--word = ''
		while word ~= '' do
			cVowel, nVowel, sBreak, stress = false, false, false, false
			
			--First thing is to find the first vowel.
			searching = 1
			cVowelFound = false
			while not cVowel do
				letter = mw.ustring.sub(word, searching, searching)
				if cVowelFound then
					if iVows[letter] or iCons[letter] or letter == '' or letter == 'ˈ' then
						cVowel = searching - 1
					elseif iDias[letter] then
						searching = searching + 1
					elseif letter == d1 then
						cVowelFound = false
						searching = searching + 1
					else
						searching = searching + 1
					end
				else
					if iVows[letter] then
						cVowelFound = true
					elseif letter == 'ˈ' then
						stress = true
					elseif letter == '' then  --This shouldn't happen.
						cVowel = true
						wordEnd = true
					end
					searching = searching + 1
				end
			end
		
			--Next we try and find the next vowel or the end.
			searching = cVowel + 1
			while (not nVowel) and (not wordEnd) do
				letter = mw.ustring.sub(word, searching, searching)
				if iVows[letter] or letter == 'ˈ' then
					nVowel = searching
				elseif letter == '' then
					wordEnd = true
				else
					searching = searching + 1
				end
			end
			
			--Finally we find the syllable break point.
			if wordEnd then
				sBreak = mw.ustring.len(word)
			elseif iLiqs[mw.ustring.sub(word, nVowel-1, nVowel-1)] then
				if iStops[mw.ustring.sub(word, nVowel-2, nVowel-2)] then
					sBreak = nVowel - 3
				elseif mw.ustring.sub(word, nVowel-2, nVowel-2) == 'ʰ' and iStops[mw.ustring.sub(word, nVowel-3, nVowel-3)] then
					sBreak = nVowel - 4
				else
					sBreak = nVowel - 2
				end
			elseif iCons[mw.ustring.sub(word, nVowel-1, nVowel-1)] then
				sBreak = nVowel - 2
			elseif mw.ustring.sub(word, nVowel-1, nVowel-1) == 'ʰ' and iStops[mw.ustring.sub(word, nVowel-2, nVowel-2)] then
				sBreak = nVowel - 3
			elseif mw.ustring.sub(word, nVowel-1, nVowel-1) == '̥' and mw.ustring.sub(word, nVowel-2, nVowel-2) == 'r' then
				sBreak = nVowel - 3
			else
				sBreak = nVowel - 1
			end
			
			--Pull everything up to and including the syllable Break.
			local syllable = mw.ustring.sub(word, 1, sBreak)
			
			--If there is a stress accent, then we need to move it to the 
			--beginning of the syllable, unless it is a monosyllabic word,
			--in which case we remove it altogether.
			if stress then
				if next(syllables) or syllable ~= word then
					syllable = 'ˈ'..mw.ustring.gsub(syllable, 'ˈ', '')
				else 
					syllable = mw.ustring.gsub(syllable, 'ˈ', '')
				end
				stress = false
			end
			table.insert(syllables, syllable)
			word = mw.ustring.sub(word, sBreak+1)
		end
		
		if #syllables > 0 then
			IPAs[period].IPA = table.concat(syllables, '.')
		end
	end	
	
	--Final format
	local inlineProns = '<div class="vsShow" style="display: none;">\n* IPA: '
	for i=1, #inlinePeriods do
		period = inlinePeriods[i]
		inlineProns = inlineProns..'<span class="IPA" lang="grc">/'..IPAs[period].IPA..'/</span>'
		if period ~= 'byz2' then
			inlineProns = inlineProns..' → '
		end
	end
	local inlineProns = inlineProns..'</div>'
	local fullProns = '<div class="vsHide">\n'
	for i=1, #periods do
		period = periods[i]
		local notes = ''
		if #IPAs[period].notes > 0 then
			notes = '  <span class="previewonly">'..table.concat(IPAs[period].notes, ', ')..'</span>'
		end
		fullProns = fullProns..'* '..periodLabels[period]..': IPA: <span class="IPA" lang="grc">/'..IPAs[period].IPA..'/</span>'..notes
		if period ~= 'byz2' then
			fullProns = fullProns..'\n'
		end
	end
	fullProns = fullProns..'</div>'
	local final = '<div class="vsSwitcher vsToggleCategory-pronunciations" style="white-space: nowrap; width: max-content;"><div style="float: right;"><span class="vsToggleElement" style="float: right;">&nbsp;</span></div><div style="float: right;">'..inlineProns..fullProns..'</div></div>'
	return final
end

return export
--Things we still need:
--Voicing of sigma around (after?) voiced stops. 
--Proper alerts for editors, especially on ambiguous vowels.