Module:vi-pron

Definition from Wiktionary, the free dictionary
Jump to: navigation, search
The following documentation is located at Module:vi-pron/documentation. [edit]
See also: subpages of this module.

Pronunciation module for Vietnamese.


local export={}
 
function export.make(frame)
	local ipa={}
	local p={}
	local initial={}
	local final={}
	local finaldetone={}
	local tone={}
	local loc=frame.args["loc"]
	for i,item in ipairs(frame.args) do
		table.insert(p, (item ~= "") and mw.ustring.lower(item) or nil)
	end
	for i, p_i in ipairs(p) do
		if mw.ustring.sub(p[i],1,3) == 'ngh' then
			initial[i] = 'ngh'
			final[i] = mw.ustring.sub(p[i],4,-1)
		elseif mw.ustring.gsub(mw.ustring.sub(p[i],1,2),'[cgknpt][higry]',{['ch']='',['gh']='',['gi']='',['kh']='',['ng']='',['nh']='',['ph']='',['th']='',['tr']='',['gy']=''}) == '' then
			initial[i] = mw.ustring.sub(p[i],1,2)
			final[i] = mw.ustring.sub(p[i],3,-1)
		elseif mw.ustring.gsub(mw.ustring.sub(p[i],1,1),'[bcdđghklmnqrstvx]','') == '' then
			initial[i] = mw.ustring.sub(p[i],1,1)
			final[i] = mw.ustring.sub(p[i],2,-1)
		else
			initial[i] = 'ø'
			final[i] = p[i]
		end
		if mw.ustring.match(final[i],'[àằầèềìòồờùừỳ]') then
			tone[i] = 2
		elseif mw.ustring.match(final[i],'[áắấéếíóốớúứý]') then
			tone[i] = 3
		elseif mw.ustring.match(final[i],'[ảẳẩẻểỉỏổởủửỷ]') then
			tone[i] = 4
		elseif mw.ustring.match(final[i],'[ãẵẫẽễĩõỗỡũữỹ]') then
			tone[i] = 5
		elseif mw.ustring.match(final[i],'[ạặậẹệịọộợụựỵ]') then
			tone[i] = 6
		else
			tone[i] = 1
		end
		finaldetone[i] = mw.ustring.gsub(final[i],'.',{['à']='a',['ằ']='ă',['ầ']='â',['è']='e',['ề']='ê',['ì']='i',['ò']='o',['ồ']='ô',['ờ']='ơ',['ù']='u',['ừ']='ư',['ỳ']='y',['á']='a',['ắ']='ă',['ấ']='â',['é']='e',['ế']='ê',['í']='i',['ó']='o',['ố']='ô',['ớ']='ơ',['ú']='u',['ứ']='ư',['ý']='y',['ả']='a',['ẳ']='ă',['ẩ']='â',['ẻ']='e',['ể']='ê',['ỉ']='i',['ỏ']='o',['ổ']='ô',['ở']='ơ',['ủ']='u',['ử']='ư',['ỷ']='y',['ã']='a',['ẵ']='ă',['ẫ']='â',['ẽ']='e',['ễ']='ê',['ĩ']='i',['õ']='o',['ỗ']='ô',['ỡ']='ơ',['ũ']='u',['ữ']='ư',['ỹ']='y',['ạ']='a',['ặ']='ă',['ậ']='â',['ẹ']='e',['ệ']='ê',['ị']='i',['ọ']='o',['ộ']='ô',['ợ']='ơ',['ụ']='u',['ự']='ư',['ỵ']='y'})
		if loc == 'hn' then
			ipa[i] = mw.ustring.gsub(initial[i],'[bcdđghklmnqrstvxpø][higr]?[h]?',{['b']='ˀɓ',['c']='k',['ch']='ṯɕ',['tr']='ṯɕ',['d']='z̻',['đ']='ˀɗ',['g']='ɣ',['gh']='ɣ',['gi']='z̻',['gy']='z̻',['h']='h',['k']='k',['kh']='x',['l']='l̪',['m']='m',['n']='n',['ng']='ŋ',['ngh']='ŋ',['nh']='ɲ',['ph']='f',['q']='k',['r']='z',['s']='s̪',['t']='t',['th']='tʰ',['v']='v',['x']='s̪',['ø']='ʔ'})
			if initial[i] == 'q' then
				ipa[i] = (ipa[i] .. mw.ustring.gsub(finaldetone[i],'[aăâeêioôơuưy][aâăeêioôơuưy]?[aêiuy]?[mncptk]?[hg]?',{['a']='aː',['ac']='aːʔk̚',['ach']='ɐɪʔk̟̚',['ai']='aːj',['am']='aːm',['an']='aːn',['ang']='aːŋ',['anh']='ɐjŋ̟',['ao']='aːw',['ap']='aːʔp̚',['at']='aːʔt̚',['au']='ɐw',['ay']='ɐj',['ăc']='ɐʔk̚',['ăm']='ɐm',['ăn']='ɐn',['ăng']='ɐŋ',['ăp']='ɐʔp̚',['ăt']='ɐʔt̚',['â']='ɜ',['âc']='ɜʔk̚',['âm']='ɜm',['ân']='ɜn',['âng']='ɜŋ',['ânh']='ɜjŋ̟',['âp']='ɜʔp̚',['ât']='ɜʔt̚',['âu']='ɜw',['ây']='ɜj',['e']='ɛ',['ec']='ɛʔk̚',['em']='ɛm',['en']='ɛn',['eng']='ɛŋ',['eo']='ɛw',['ep']='ɛʔp̚',['et']='ɛʔt̚',['ê']='e',['êc']='eʔk̚',['êch']='ɜjʔk̟̚',['êm']='em',['ên']='en',['êng']='eŋ',['ênh']='ɜjŋ̟',['êp']='eʔp̚',['êt']='eʔt̚',['êu']='ew',['i']='i',['ia']='iɜ',['ich']='ïʔk̟̚',['iêc']='iɜʔk̚',['iêm']='iɜm',['iên']='iɜn',['iêng']='iɜŋ',['iêp']='iɜʔp̚',['iêt']='iɜʔt̚',['iêu']='iɜw',['im']='im',['ym']='im',['in']='in',['inh']='ïŋ',['ip']='iʔp̚',['it']='iʔt̚',['iu']='iw',['o']='ɔ',['oa']='waː',['oac']='waːʔk̚',['oach']='wɐjʔk̟̚',['oai']='waːj',['oam']='waːm',['oan']='waːn',['oang']='waːŋ',['oanh']='wɐjŋ̟',['oao']='waːw',['oap']='waːʔp̚',['oat']='waːʔt̚',['oay']='wɐj',['oăc']='wɐʔk̚',['oăm']='wɐm',['oăn']='wɐn',['oăng']='wɐŋ',['oăt']='wɐʔt̚',['oc']='ɐwʔk͡p̚',['oe']='wɛ',['oen']='wɛn',['oeo']='wɛw',['oet']='wɛʔt̚',['oi']='ɔj',['om']='ɔm',['on']='ɔn',['ong']='ɐwŋ͡m',['oong']='ɔŋ',['op']='ɔʔp̚',['ot']='ɔʔt̚',['ô']='o',['ôc']='ɜwʔk͡p̚',['ôi']='oj',['ôm']='om',['ôn']='on',['ông']='ɜwŋ͡m',['ôông']='oŋ',['ôp']='oʔp̚',['ôt']='oʔt̚',['ơ']='əːɰ',['ơi']='əːj',['ơm']='əːm',['ơn']='əːn',['ơng']='əːŋ',['ơp']='əːʔp̚',['ơt']='əːʔt̚',['ơu']='ɜw',['u']='u',['ua']='waː',['uac']='waːʔk̚',['uach']='wɐɪʔk̟̚',['uai']='waːj',['uan']='waːn',['uang']='waːŋ',['uanh']='wɐɪŋ̟',['uao']='waːw',['uat']='waːʔt̚',['uau']='wɐw',['uay']='wɐj',['uăc']='wɐʔk̚',['uăm']='wɐm',['uăn']='wɐn',['uăng']='wɐŋ',['uăp']='wɐʔp̚',['uăt']='wɐʔt̚',['uâc']='wɜʔk̚',['uân']='wɜn',['uâng']='wɜŋ',['uât']='wɜʔt̚',['uây']='wɜj',['uc']='uwʔk͡p̚',['ue']='wɛ',['uen']='wɛn',['ueo']='wɛw',['uep']='wɛʔp̚',['uet']='wɛʔt̚',['uê']='wej',['uêch']='wɜjʔk̟̚',['uên']='wen',['uênh']='wɜjŋ̟',['uêt']='weʔt̚',['uêu']='weu',['ui']='uj',['uit']='wiʔt̚',['um']='um',['un']='un',['ung']='uwŋ͡m',['unh']='ujŋ̟',['uôc']='uɜʔk̚',['uôi']='uɜj',['uôm']='uɜm',['uôn']='uɜn',['uông']='uɜŋ',['uôt']='uɜʔt̚',['uơ']='uɜ',['uơi']='uɜj',['uơn']='uɜn',['uơt']='uɜʔt̚',['up']='uʔp̚',['ut']='uʔt̚',['uy']='wi',['uya']='wiɜ',['uych']='wïʔk̟̚',['uich']='wïʔk̟̚',['uyêc']='wiɜʔk̚',['uyên']='wiɜn',['uyênh']='wiɜŋ̟',['uyêt']='wiɜʔt̚',['uynh']='wïŋ̟',['uyt']='wiʔt̚',['uyu']='wiw',['ư']='ɨ̞̠',['ưa']='ɨ̞̠ɜ',['ưc']='ɨ̞̠ʔk̚',['ưi']='ɨ̞̠j',['ưn']='ɨ̞̠n',['ưng']='ɨ̞̠ŋ',['ươc']='ɨ̞̠ɜʔk̚',['ươi']='ɨ̞̠ɜj',['ươm']='ɨ̞̠ɜm',['ươn']='ɨ̞̠ɜn',['ương']='ɨ̞̠ɜŋ',['ươp']='ɨ̞̠ɜʔp̚',['ươt']='ɨ̞̠ɜʔt̚',['ươu']='iɜw',['ưt']='ɨ̞̠ʔt̚',['ưu']='iw',['wui']='wuj',['y']='i',['yêc']='iɜʔk̚',['yêm']='iɜm',['yên']='iɜn',['yêng']='iɜŋ',['yêp']='iɜʔp̚',['yêt']='iɜʔt̚',['yêu']='iɜw'}))
			else
				ipa[i] = (ipa[i] .. mw.ustring.gsub(finaldetone[i],'[aăâeêioôơuưy][aâăeêioôơuưy]?[aêiuy]?[mncptk]?[hg]?',{['a']='aː',['ac']='aːʔk̚',['ach']='ɐɪʔk̟̚',['ai']='aːj',['am']='aːm',['an']='aːn',['ang']='aːŋ',['anh']='ɐjŋ̟',['ao']='aːw',['ap']='aːʔp̚',['at']='aːʔt̚',['au']='ɐw',['ay']='ɐj',['ăc']='ɐʔk̚',['ăm']='ɐm',['ăn']='ɐn',['ăng']='ɐŋ',['ăp']='ɐʔp̚',['ăt']='ɐʔt̚',['â']='ɜ',['âc']='ɜʔk̚',['âm']='ɜm',['ân']='ɜn',['âng']='ɜŋ',['ânh']='ɜjŋ̟',['âp']='ɜʔp̚',['ât']='ɜʔt̚',['âu']='ɜw',['ây']='ɜj',['e']='ɛ',['ec']='ɛʔk̚',['em']='ɛm',['en']='ɛn',['eng']='ɛŋ',['eo']='ɛw',['ep']='ɛʔp̚',['et']='ɛʔt̚',['ê']='e',['êc']='eʔk̚',['êch']='ɜjʔk̟̚',['êm']='em',['ên']='en',['êng']='eŋ',['ênh']='ɜjŋ̟',['êp']='eʔp̚',['êt']='eʔt̚',['êu']='ew',['i']='i',['ia']='iɜ',['ich']='ïʔk̟̚',['iêc']='iɜʔk̚',['iêm']='iɜm',['iên']='iɜn',['iêng']='iɜŋ',['iêp']='iɜʔp̚',['iêt']='iɜʔt̚',['iêu']='iɜw',['im']='im',['ym']='im',['in']='in',['inh']='ïŋ',['ip']='iʔp̚',['it']='iʔt̚',['iu']='iw',['o']='ɔ',['oa']='waː',['oac']='waːʔk̚',['oach']='wɐjʔk̟̚',['oai']='waːj',['oam']='waːm',['oan']='waːn',['oang']='waːŋ',['oanh']='wɐjŋ̟',['oao']='waːw',['oap']='waːʔp̚',['oat']='waːʔt̚',['oay']='wɐj',['oăc']='wɐʔk̚',['oăm']='wɐm',['oăn']='wɐn',['oăng']='wɐŋ',['oăt']='wɐʔt̚',['oc']='ɐwʔk͡p̚',['oe']='wɛ',['oen']='wɛn',['oeo']='wɛw',['oet']='wɛʔt̚',['oi']='ɔj',['om']='ɔm',['on']='ɔn',['ong']='ɐwŋ͡m',['oong']='ɔŋ',['op']='ɔʔp̚',['ot']='ɔʔt̚',['ô']='o',['ôc']='ɜwʔk͡p̚',['ôi']='oj',['ôm']='om',['ôn']='on',['ông']='ɜwŋ͡m',['ôông']='oŋ',['ôp']='oʔp̚',['ôt']='oʔt̚',['ơ']='əːɰ',['ơi']='əːj',['ơm']='əːm',['ơn']='əːn',['ơng']='əːŋ',['ơp']='əːʔp̚',['ơt']='əːʔt̚',['ơu']='ɜw',['u']='u',['ua']='uɜ',['uac']='waːʔk̚',['uach']='wɐɪʔk̟̚',['uai']='waːj',['uan']='waːn',['uang']='waːŋ',['uanh']='wɐɪŋ̟',['uao']='waːw',['uat']='waːʔt̚',['uau']='wɐw',['uay']='wɐj',['uăc']='wɐʔk̚',['uăm']='wɐm',['uăn']='wɐn',['uăng']='wɐŋ',['uăp']='wɐʔp̚',['uăt']='wɐʔt̚',['uâc']='wɜʔk̚',['uân']='wɜn',['uâng']='wɜŋ',['uât']='wɜʔt̚',['uây']='wɜj',['uc']='uwʔk͡p̚',['ue']='wɛ',['uen']='wɛn',['ueo']='wɛw',['uep']='wɛʔp̚',['uet']='wɛʔt̚',['uê']='wej',['uêch']='wɜjʔk̟̚',['uên']='wen',['uênh']='wɜjŋ̟',['uêt']='weʔt̚',['uêu']='weu',['ui']='uj',['uit']='wiʔt̚',['um']='um',['un']='un',['ung']='uwŋ͡m',['unh']='ujŋ̟',['uôc']='uɜʔk̚',['uôi']='uɜj',['uôm']='uɜm',['uôn']='uɜn',['uông']='uɜŋ',['uôt']='uɜʔt̚',['uơ']='uɜ',['uơi']='uɜj',['uơn']='uɜn',['uơt']='uɜʔt̚',['up']='uʔp̚',['ut']='uʔt̚',['uy']='wi',['uya']='wiɜ',['uych']='wïʔk̟̚',['uich']='wïʔk̟̚',['uyêc']='wiɜʔk̚',['uyên']='wiɜn',['uyênh']='wiɜŋ̟',['uyêt']='wiɜʔt̚',['uynh']='wïŋ̟',['uyt']='wiʔt̚',['uyu']='wiw',['ư']='ɨ̞̠',['ưa']='ɨ̞̠ɜ',['ưc']='ɨ̞̠ʔk̚',['ưi']='ɨ̞̠j',['ưn']='ɨ̞̠n',['ưng']='ɨ̞̠ŋ',['ươc']='ɨ̞̠ɜʔk̚',['ươi']='ɨ̞̠ɜj',['ươm']='ɨ̞̠ɜm',['ươn']='ɨ̞̠ɜn',['ương']='ɨ̞̠ɜŋ',['ươp']='ɨ̞̠ɜʔp̚',['ươt']='ɨ̞̠ɜʔt̚',['ươu']='iɜw',['ưt']='ɨ̞̠ʔt̚',['ưu']='iw',['wui']='wuj',['y']='i',['yêc']='iɜʔk̚',['yêm']='iɜm',['yên']='iɜn',['yêng']='iɜŋ',['yêp']='iɜʔp̚',['yêt']='iɜʔt̚',['yêu']='iɜw'}))
			end
			if tone[i] == 1 then
				ipa[i] = (ipa[i] .. '˧˧')
			elseif tone[i] == 2 then
				ipa[i] = (ipa[i] .. '˨˩')
			elseif tone[i] == 3 then
				ipa[i] = (ipa[i] .. '˧ˀ˦')
			elseif tone[i] == 4 then
				ipa[i] = (ipa[i] .. '˧˩')
			elseif tone[i] == 5 then
				ipa[i] = (ipa[i] .. '˦ˀ˥')
			elseif tone[i] == 6 then
				ipa[i] = (ipa[i] .. '˧ˀ˨ʔ')
			end
		elseif loc == 'hue'	then
			ipa[i] = mw.ustring.gsub(initial[i],'[bcdđghklmnqrstvxpø][higr]?[h]?',{['b']='ˀɓ',['c']='k',['ch']='ṯɕ',['d']='j',['đ']='ˀɗ',['g']='ɣ',['gh']='ɣ',['gi']='j',['gy']='j',['h']='h',['k']='k',['kh']='x',['l']='l',['m']='m',['n']='n',['ng']='ŋ',['ngh']='ŋ',['nh']='ɲ',['ph']='f',['q']='k',['r']='ʐ',['s']='ʂ',['t']='t',['th']='tʰ',['tr']='ʈ',['v']='v',['x']='s̪',['ø']='ʔ'})
			if initial[i] == 'q' then
				ipa[i] = (ipa[i] .. mw.ustring.gsub(finaldetone[i],'[aăâeêioôơuưy][aâăeêioôơuưy]?[aêiuy]?[mncptk]?[hg]?',{['a']='aː',['ac']='aːʔk̚',['ach']='ɐʔt̚',['ai']='aːj',['am']='aːm',['an']='aːŋ',['ang']='aːŋ',['anh']='ɐn',['ao']='aːw',['ap']='aːʔp̚',['at']='aːʔk̚',['au']='ɐw',['ay']='ɐj',['ăc']='ɐʔk̚',['ăm']='ɐm',['ăn']='ɐŋ',['ăng']='ɐŋ',['ăp']='ɐʔp̚',['ăt']='ɐʔk̚',['â']='ɜ',['âc']='ɜʔk̚',['âm']='ɜm',['ân']='ɜŋ',['âng']='ɜŋ',['ânh']='ɜn',['âp']='ɜʔp̚',['ât']='ɜʔk̚',['âu']='ɜw',['ây']='ɜj',['e']='ɛ',['ec']='ɛʔk̚',['em']='ɛm',['en']='ɛŋ',['eng']='ɛŋ',['eo']='ɛw',['ep']='ɛʔp̚',['et']='ɛʔt̚',['ê']='ej',['êc']='eʔk̚',['êch']='eʔt̚',['êm']='em',['ên']='en',['êng']='eŋ',['ênh']='en',['êp']='eʔp̚',['êt']='eʔt̚',['êu']='ew',['i']='ɪj',['ia']='iɜ',['ich']='ɨ̞̠ʔt̚',['iêc']='iɜʔk̚',['iêm']='iɜm',['iên']='iɜŋ',['iêng']='iɜŋ',['iêp']='iɜʔp̚',['iêt']='iɜʔk̚',['iêu']='iɜw',['im']='im',['ym']='im',['in']='in',['inh']='ɨ̞̠n',['ip']='iʔp̚',['it']='iʔt̚',['iu']='iw',['o']='ɔ',['oa']='waː',['oac']='waːʔk̚',['oach']='wɐʔt̚',['oai']='waːj',['oam']='waːm',['oan']='waːŋ',['oang']='waːŋ',['oanh']='wɐn',['oao']='waːw',['oap']='waːʔp̚',['oat']='waːʔk̚',['oay']='wɐj',['oăc']='wɐʔk̚',['oăm']='wɐm',['oăn']='wɐŋ',['oăng']='wɐŋ',['oăt']='wɐʔk̚',['oc']='ɐwʔk͡p̚',['oe']='wɛ',['oen']='wɛŋ',['oeo']='wɛw',['oet']='wɛʔk̚',['oi']='ɔj',['om']='ɔm',['on']='ɔŋ',['ong']='ɐwŋ',['oong']='ɔŋ͡m',['op']='ɔʔp̚',['ot']='ɔʔk̚',['ô']='ow',['ôc']='ɜwʔk͡p̚',['ôi']='oj',['ôm']='om',['ôn']='oŋ',['ông']='ɜwŋ͡m',['ôông']='oŋ',['ôp']='oʔp̚',['ôt']='oʔk̚',['ơ']='əːɰ',['ơi']='əːj',['ơm']='əːm',['ơn']='əːŋ',['ơng']='əːŋ',['ơp']='əːʔp̚',['ơt']='əːʔk̚',['ơu']='əːw',['u']='ʊw',['ua']='waː',['uac']='waːʔk̚',['uach']='wɐt̚',['uai']='waːj',['uan']='waːŋ',['uang']='waːŋ',['uanh']='wɐn',['uao']='waːw',['uat']='waːʔk̚',['uau']='wɐw',['uay']='wɐj',['uăc']='wɐʔk̚',['uăm']='wɐm',['uăn']='wɐŋ',['uăng']='wɐŋ',['uăp']='wɐʔp̚',['uăt']='wɐʔk̚',['uâc']='wɜʔk̚',['uân']='wɜŋ',['uâng']='wɜŋ',['uât']='wɜʔk̚',['uây']='wɜj',['uc']='uwʔk͡p̚',['ue']='wɛ',['uen']='wɛŋ',['ueo']='wɛw',['uep']='wɛʔp̚',['uet']='wɛʔt̚',['uê']='wej',['uêch']='weʔt̚',['uên']='wen',['uênh']='wen',['uêt']='weʔt̚',['uêu']='weu',['ui']='uj',['uit']='wiʔt̚',['um']='um',['un']='un',['ung']='uwŋ͡m',['unh']='un',['uôc']='uɜʔk̚',['uôi']='uj',['uôm']='uɜm',['uôn']='uɜŋ',['uông']='uɜŋ',['uôt']='uɜʔk̚',['uơ']='wəː',['uơi']='wɜj',['uơn']='wɜŋ',['uơt']='wɜʔk̚',['up']='uʔp̚',['ut']='uʔk̚',['uy']='wi',['uya']='wiɜ',['uych']='wɨ̞̠ʔk̟̚',['uich']='wɨ̞̠ʔk̟̚',['uyêc']='wiɜʔk̚',['uyên']='wiɜŋ',['uyênh']='wiɜn',['uyêt']='wiɜʔk̚',['uynh']='wɨ̞̠n',['uyt']='wɨ̞̠ʔt̚',['uyu']='wiw',['ư']='ɨ̞̠ɰ',['ưa']='ɨ̞̠ɜ',['ưc']='ɨ̞̠ʔk̚',['ưi']='ɨ̞̠j',['ưn']='ɨ̞̠ŋ',['ưng']='ɨ̞̠ŋ',['ươc']='ɨ̞̠ɜʔk̚',['ươi']='ɨ̞̠ɜj',['ươm']='ɨ̞̠ɜm',['ươn']='ɨ̞̠ɜŋ',['ương']='ɨ̞̠ɜŋ',['ươp']='ɨ̞̠ɜʔp̚',['ươt']='ɨ̞̠ɜʔk̚',['ươu']='ɨ̞̠ɜw',['ưt']='ɨ̞̠ʔk̚',['ưu']='ɨ̞̠w',['wui']='wuj',['y']='ɪj',['yêc']='iɜʔk̚',['yêm']='iɜm',['yên']='iɜŋ',['yêng']='iɜŋ',['yêp']='iɜʔp̚',['yêt']='iɜʔk̚',['yêu']='iɜw'}))
			else
				ipa[i] = (ipa[i] .. mw.ustring.gsub(finaldetone[i],'[aăâeêioôơuưy][aâăeêioôơuưy]?[aêiuy]?[mncptk]?[hg]?',{['a']='aː',['ac']='aːʔk̚',['ach']='ɐʔt̚',['ai']='aːj',['am']='aːm',['an']='aːŋ',['ang']='aːŋ',['anh']='ɐn',['ao']='aːw',['ap']='aːʔp̚',['at']='aːʔk̚',['au']='ɐw',['ay']='ɐj',['ăc']='ɐʔk̚',['ăm']='ɐm',['ăn']='ɐŋ',['ăng']='ɐŋ',['ăp']='ɐʔp̚',['ăt']='ɐʔk̚',['â']='ɜ',['âc']='ɜʔk̚',['âm']='ɜm',['ân']='ɜŋ',['âng']='ɜŋ',['ânh']='ɜn',['âp']='ɜʔp̚',['ât']='ɜʔk̚',['âu']='ɜw',['ây']='ɜj',['e']='ɛ',['ec']='ɛʔk̚',['em']='ɛm',['en']='ɛŋ',['eng']='ɛŋ',['eo']='ɛw',['ep']='ɛʔp̚',['et']='ɛʔt̚',['ê']='ej',['êc']='eʔk̚',['êch']='eʔt̚',['êm']='em',['ên']='en',['êng']='eŋ',['ênh']='en',['êp']='eʔp̚',['êt']='eʔt̚',['êu']='ew',['i']='ɪj',['ia']='iɜ',['ich']='ɨ̞̠ʔt̚',['iêc']='iɜʔk̚',['iêm']='iɜm',['iên']='iɜŋ',['iêng']='iɜŋ',['iêp']='iɜʔp̚',['iêt']='iɜʔk̚',['iêu']='iɜw',['im']='im',['ym']='im',['in']='in',['inh']='ɨ̞̠n',['ip']='iʔp̚',['it']='iʔt̚',['iu']='iw',['o']='ɔ',['oa']='waː',['oac']='waːʔk̚',['oach']='wɐʔt̚',['oai']='waːj',['oam']='waːm',['oan']='waːŋ',['oang']='waːŋ',['oanh']='wɐn',['oao']='waːw',['oap']='waːʔp̚',['oat']='waːʔk̚',['oay']='wɐj',['oăc']='wɐʔk̚',['oăm']='wɐm',['oăn']='wɐŋ',['oăng']='wɐŋ',['oăt']='wɐʔk̚',['oc']='ɐwʔk͡p̚',['oe']='wɛ',['oen']='wɛŋ',['oeo']='wɛw',['oet']='wɛʔk̚',['oi']='ɔj',['om']='ɔm',['on']='ɔŋ',['ong']='ɐwŋ',['oong']='ɔŋ͡m',['op']='ɔʔp̚',['ot']='ɔʔk̚',['ô']='ow',['ôc']='ɜwʔk͡p̚',['ôi']='oj',['ôm']='om',['ôn']='oŋ',['ông']='ɜwŋ͡m',['ôông']='oŋ',['ôp']='oʔp̚',['ôt']='oʔk̚',['ơ']='əːɰ',['ơi']='əːj',['ơm']='əːm',['ơn']='əːŋ',['ơng']='əːŋ',['ơp']='əːʔp̚',['ơt']='əːʔk̚',['ơu']='əːw',['u']='ʊw',['ua']='uɜ',['uac']='waːʔk̚',['uach']='wɐt̚',['uai']='waːj',['uan']='waːŋ',['uang']='waːŋ',['uanh']='wɐn',['uao']='waːw',['uat']='waːʔk̚',['uau']='wɐw',['uay']='wɐj',['uăc']='wɐʔk̚',['uăm']='wɐm',['uăn']='wɐŋ',['uăng']='wɐŋ',['uăp']='wɐʔp̚',['uăt']='wɐʔk̚',['uâc']='wɜʔk̚',['uân']='wɜŋ',['uâng']='wɜŋ',['uât']='wɜʔk̚',['uây']='wɜj',['uc']='uwʔk͡p̚',['ue']='wɛ',['uen']='wɛŋ',['ueo']='wɛw',['uep']='wɛʔp̚',['uet']='wɛʔt̚',['uê']='wej',['uêch']='weʔt̚',['uên']='wen',['uênh']='wen',['uêt']='weʔt̚',['uêu']='weu',['ui']='uj',['uit']='wiʔt̚',['um']='um',['un']='un',['ung']='uwŋ͡m',['unh']='un',['uôc']='uɜʔk̚',['uôi']='uj',['uôm']='uɜm',['uôn']='uɜŋ',['uông']='uɜŋ',['uôt']='uɜʔk̚',['uơ']='wəː',['uơi']='wɜj',['uơn']='wɜŋ',['uơt']='wɜʔk̚',['up']='uʔp̚',['ut']='uʔk̚',['uy']='wi',['uya']='wiɜ',['uych']='wɨ̞̠ʔk̟̚',['uich']='wɨ̞̠ʔk̟̚',['uyêc']='wiɜʔk̚',['uyên']='wiɜŋ',['uyênh']='wiɜn',['uyêt']='wiɜʔk̚',['uynh']='wɨ̞̠n',['uyt']='wɨ̞̠ʔt̚',['uyu']='wiw',['ư']='ɨ̞̠ɰ',['ưa']='ɨ̞̠ɜ',['ưc']='ɨ̞̠ʔk̚',['ưi']='ɨ̞̠j',['ưn']='ɨ̞̠ŋ',['ưng']='ɨ̞̠ŋ',['ươc']='ɨ̞̠ɜʔk̚',['ươi']='ɨ̞̠ɜj',['ươm']='ɨ̞̠ɜm',['ươn']='ɨ̞̠ɜŋ',['ương']='ɨ̞̠ɜŋ',['ươp']='ɨ̞̠ɜʔp̚',['ươt']='ɨ̞̠ɜʔk̚',['ươu']='ɨ̞̠ɜw',['ưt']='ɨ̞̠ʔk̚',['ưu']='ɨ̞̠w',['wui']='wuj',['y']='ɪj',['yêc']='iɜʔk̚',['yêm']='iɜm',['yên']='iɜŋ',['yêng']='iɜŋ',['yêp']='iɜʔp̚',['yêt']='iɜʔk̚',['yêu']='iɜw'}))
			end
			if tone[i] == 1 then
				ipa[i] = (ipa[i] .. '˧˧')
			elseif tone[i] == 2 then
				ipa[i] = (ipa[i] .. '˧˧')
			elseif tone[i] == 3 then
				if mw.ustring.match(finaldetone[i],'[chmngpt]') then
					ipa[i] = (ipa[i] .. '˦˥')
				else
					ipa[i] = (ipa[i] .. '˩ˀ˧')
				end
			elseif tone[i] == 4 then
				ipa[i] = (ipa[i] .. '˧˩')
			elseif tone[i] == 5 then
				ipa[i] = (ipa[i] .. '˧˩')
			elseif tone[i] == 6 then
				ipa[i] = (ipa[i] .. '˨ˀ˨ʔ')
			end
		elseif loc == 'hcmc' then
			if mw.ustring.gsub(finaldetone[i],'[ou][aăeâêôơy][ioyêu]?[cmntp]?[hg]?',{['oa']='',['oac']='',['oach']='',['oai']='',['oam']='',['oan']='',['oang']='',['oanh']='',['oao']='',['oat']='',['oay']='',['oăc']='',['oăm']='',['oăn']='',['oăng']='',['oăt']='',['oe']='',['oen']='',['oeo']='',['oet']='',['ua']='',['uach']='',['uai']='',['uan']='',['uang']='',['uanh']='',['uat']='',['uay']='',['uăc']='',['uăm']='',['uăn']='',['uăng']='',['uăp']='',['uăt']='',['uâc']='',['uân']='',['uâng']='',['uât']='',['uây']='',['ue']='',['uen']='',['ueo']='',['uet']='',['uê']='',['uêch']='',['uên']='',['uênh']='',['uêt']='',['uôc']='',['uơ']='',['uơn']='',['uơt']='',['uy']='',['uya']='',['uych']='',['uyên']='',['uyêt']='',['uynh']='',['uyt']='',['uyu']=''}) == '' then
				ipa[i] = mw.ustring.gsub(initial[i],'[bcdđghklmnqrstvxpø][higr]?[h]?',{['b']='ˀɓ',['c']='k',['ch']='c̻',['d']='j',['đ']='ˀɗ',['g']='ɣ',['gh']='ɣ',['gi']='j',['gy']='j',['h']='',['k']='k',['kh']='x',['l']='l̻ʲ',['m']='m',['n']='n',['ng']='(ŋ)',['ngh']='(ŋ)',['nh']='ɲ̻',['ph']='f',['q']='',['r']='ʐ',['s']='ʂ',['t']='t',['th']='tʰ',['tr']='ʈ',['v']='vʲ',['x']='s̪',['ø']='ʔ'})
			else
				ipa[i] = mw.ustring.gsub(initial[i],'[bcdđghklmnqrstvxpø][higr]?[h]?',{['b']='ˀɓ',['c']='k',['ch']='c̻',['d']='j',['đ']='ˀɗ',['g']='ɣ',['gh']='ɣ',['gi']='j',['gy']='j',['h']='h',['k']='k',['kh']='x',['l']='l̻ʲ',['m']='m',['n']='n',['ng']='ŋ',['ngh']='ŋ',['nh']='ɲ̻',['ph']='f',['q']='k',['r']='ʐ',['s']='ʂ',['t']='t',['th']='tʰ',['tr']='ʈ',['v']='vʲ',['x']='s̪',['ø']='ʔ'})
			end
			if initial[i] == 'q' then
				if mw.ustring.gsub(initial[i],'[tcxsdl][hr]?',{['th']='',['ch']='',['tr']='',['x']='',['s']='',['d']='',['l']='',['t']=''}) == '' then
					ipa[i] = (ipa[i] .. mw.ustring.gsub(finaldetone[i],'[aăâeêioôơuưy][aâăeêioôơuưy]?[aêiuy]?[mncptk]?[hg]?',{['a']='aː',['ac']='aːʔk̚',['ach']='ɐʔt̚',['ai']='aːj',['am']='aːm',['an']='aːŋ',['ang']='aːŋ',['anh']='ɐn',['ao']='aːw',['ap']='aːʔp̚',['at']='aːʔk̚',['au']='ɐw',['ay']='ɐj',['ăc']='ɐʔk̚',['ăm']='ɐm',['ăn']='ɐŋ',['ăng']='ɐŋ',['ăp']='ɐʔp̚',['ăt']='ɐʔk̚',['â']='ɜ',['âc']='ɜʔk̚',['âm']='ɜm',['ân']='ɜŋ',['âng']='ɜŋ',['ânh']='ɜn',['âp']='ɜʔp̚',['ât']='ɜʔk̚',['âu']='ɜw',['ây']='ɜj',['e']='ɛ',['ec']='ɛʔk̚',['em']='ɛm',['en']='ɛŋ',['eng']='ɛŋ',['eo']='ɛw',['ep']='ɛʔp̚',['et']='ɛʔk̚',['ê']='ej',['êc']='eʔk̚',['êch']='ɜːʔt̚',['êm']='em',['ên']='ɜːn',['êng']='eŋ',['ênh']='ɜːn',['êp']='eʔp̚',['êt']='ɜːʔt̚',['êu']='ew',['i']='ɪj',['ia']='iɜ',['ich']='ɨ̞̠ʔt̚',['iêc']='iɜʔk̚',['iêm']='iɜm',['iên']='iɜŋ',['iêng']='iɜŋ',['iêp']='iɜʔp̚',['iêt']='iɜʔk̚',['iêu']='iɜw',['im']='im',['ym']='im',['in']='ɨ̞̠n',['inh']='ɨ̞̠n',['ip']='iʔp̚',['it']='ɨ̞̠ʔt̚',['iu']='iw',['o']='ɔ',['oa']='<sup>(</sup>ʷ<sup>)</sup>aː',['oac']='<sup>(</sup>ʷ<sup>)</sup>aːʔk̚',['oach']='<sup>(</sup>ʷ<sup>)</sup>ɐʔt̚',['oai']='<sup>(</sup>ʷ<sup>)</sup>aːj',['oam']='<sup>(</sup>ʷ<sup>)</sup>aːm',['oan']='<sup>(</sup>ʷ<sup>)</sup>aːŋ',['oang']='<sup>(</sup>ʷ<sup>)</sup>aːŋ',['oanh']='<sup>(</sup>ʷ<sup>)</sup>ɐn',['oao']='<sup>(</sup>ʷ<sup>)</sup>aːw',['oap']='<sup>(</sup>ʷ<sup>)</sup>aːʔp̚',['oat']='<sup>(</sup>ʷ<sup>)</sup>aːʔk̚',['oay']='<sup>(</sup>ʷ<sup>)</sup>a(ː)j',['oăc']='<sup>(</sup>ʷ<sup>)</sup>ɐʔk̚',['oăm']='<sup>(</sup>ʷ<sup>)</sup>ɐm',['oăn']='<sup>(</sup>ʷ<sup>)</sup>ɐŋ',['oăng']='<sup>(</sup>ʷ<sup>)</sup>ɐŋ',['oăt']='<sup>(</sup>ʷ<sup>)</sup>ɐʔk̚',['oc']='a(ː)wʔk͡p̚',['oe']='<sup>(</sup>ʷ<sup>)</sup>ɛ',['oen']='<sup>(</sup>ʷ<sup>)</sup>ɛŋ',['oeo']='<sup>(</sup>ʷ<sup>)</sup>ɛw',['oet']='<sup>(</sup>ʷ<sup>)</sup>ɛʔk̚',['oi']='ɔj',['om']='ɔm',['on']='ɔŋ',['ong']='ɐwŋ͡m',['oong']='ɔŋ',['op']='ɔʔp̚',['ot']='ɔʔk̚',['ô']='ow',['ôc']='ɜwʔk͡p̚',['ôi']='oj',['ôm']='om',['ôn']='oŋ',['ông']='ɜwŋ͡m',['ôông']='oŋ',['ôp']='oʔp̚',['ôt']='oʔk̚',['ơ']='əːɰ',['ơi']='əːj',['ơm']='əːm',['ơn']='əːŋ',['ơng']='əːŋ',['ơp']='əːʔp̚',['ơt']='əːʔk̚',['ơu']='əːw',['u']='ʊw',['ua']='<sup>(</sup>ʷ<sup>)</sup>aː',['uac']='<sup>(</sup>ʷ<sup>)</sup>aːʔk̚',['uach']='<sup>(</sup>ʷ<sup>)</sup>ɐt̚',['uai']='<sup>(</sup>ʷ<sup>)</sup>aːj',['uan']='<sup>(</sup>ʷ<sup>)</sup>aːŋ',['uang']='<sup>(</sup>ʷ<sup>)</sup>aːŋ',['uanh']='<sup>(</sup>ʷ<sup>)</sup>ɐn',['uao']='<sup>(</sup>ʷ<sup>)</sup>aːw',['uat']='<sup>(</sup>ʷ<sup>)</sup>aːʔk̚',['uau']='<sup>(</sup>ʷ<sup>)</sup>a(ː)w',['uay']='<sup>(</sup>ʷ<sup>)</sup>a(ː)j',['uăc']='<sup>(</sup>ʷ<sup>)</sup>ɐʔk̚',['uăm']='<sup>(</sup>ʷ<sup>)</sup>ɐm',['uăn']='<sup>(</sup>ʷ<sup>)</sup>ɐŋ',['uăng']='<sup>(</sup>ʷ<sup>)</sup>ɐŋ',['uăp']='<sup>(</sup>ʷ<sup>)</sup>ɐʔp̚',['uăt']='<sup>(</sup>ʷ<sup>)</sup>ɐʔk̚',['uâc']='<sup>(</sup>ʷ<sup>)</sup>ɜʔk̚',['uân']='<sup>(</sup>ʷ<sup>)</sup>ɜŋ',['uâng']='<sup>(</sup>ʷ<sup>)</sup>ɜŋ',['uât']='<sup>(</sup>ʷ<sup>)</sup>ɜʔk̚',['uây']='<sup>(</sup>ʷ<sup>)</sup>ɜj',['uc']='uwʔk͡p̚',['ue']='<sup>(</sup>ʷ<sup>)</sup>ɛ',['uen']='<sup>(</sup>ʷ<sup>)</sup>ɛŋ',['ueo']='<sup>(</sup>ʷ<sup>)</sup>ɛw',['uep']='<sup>(</sup>ʷ<sup>)</sup>ɛʔp̚',['uet']='<sup>(</sup>ʷ<sup>)</sup>ɛʔt̚',['uê']='<sup>(</sup>ʷ<sup>)</sup>ej',['uêch']='<sup>(</sup>ʷ<sup>)</sup>ɜːʔt̚',['uên']='<sup>(</sup>ʷ<sup>)</sup>ɜːn',['uênh']='<sup>(</sup>ʷ<sup>)</sup>ɜːn',['uêt']='<sup>(</sup>ʷ<sup>)</sup>ɜːʔt̚',['uêu']='<sup>(</sup>ʷ<sup>)</sup>ew',['ui']='uj',['uit']='<sup>(</sup>ʷ<sup>)</sup>iʔt̚',['um']='um',['un']='uŋ͡m',['ung']='uwŋ͡m',['unh']='uwn',['uôc']='uɜʔk̚',['uôi']='uj',['uôm']='uɜm',['uôn']='uɜŋ',['uông']='uɜŋ',['uôt']='uɜʔk̚',['uơ']='<sup>(</sup>ʷ<sup>)</sup>əː',['uơi']='<sup>(</sup>ʷ<sup>)</sup>ɜj',['uơn']='<sup>(</sup>ʷ<sup>)</sup>ɜŋ',['uơt']='<sup>(</sup>ʷ<sup>)</sup>ɜʔk̚',['up']='uʔp̚',['ut']='uʔk͡p̚',['uy']='<sup>(</sup>ʷ<sup>)</sup>i',['uya']='<sup>(</sup>ʷ<sup>)</sup>iɜ',['uych']='<sup>(</sup>ʷ<sup>)</sup>ɨ̞̠ʔt̚',['uich']='<sup>(</sup>ʷ<sup>)</sup>ɨ̞̠ʔt̚',['uyêc']='<sup>(</sup>ʷ<sup>)</sup>iɜʔk̚',['uyên']='<sup>(</sup>ʷ<sup>)</sup>iɜŋ',['uyênh']='<sup>(</sup>ʷ<sup>)</sup>ɜn',['uyêt']='<sup>(</sup>ʷ<sup>)</sup>iɜʔk̚',['uynh']='<sup>(</sup>ʷ<sup>)</sup>ɨ̞̠n',['uyt']='<sup>(</sup>ʷ<sup>)</sup>ɨ̞̠ʔt̚',['uyu']='<sup>(</sup>ʷ<sup>)</sup>iw',['ư']='ɨ̞̠ɰ',['ưa']='ɨ̞̠ɜ',['ưc']='ɨ̞̠ʔk̚',['ưi']='ɨ̞̠j',['ưn']='ɨ̞̠ŋ',['ưng']='ɨ̞̠ŋ',['ươc']='ɨ̞̠ɜʔk̚',['ươi']='ɨ̞̠ɜj',['ươm']='ɨ̞̠ɜm',['ươn']='ɨ̞̠ɜŋ',['ương']='ɨ̞̠ɜŋ',['ươp']='ɨ̞̠ɜʔp̚',['ươt']='ɨ̞̠ɜʔk̚',['ươu']='ɨ̞̠ɜw',['ưt']='ɨ̞̠ʔk̚',['ưu']='ɨ̞̠w',['wui']='<sup>(</sup>ʷ<sup>)</sup>uj',['y']='ɪj',['yêc']='iɜʔk̚',['yêm']='iɜm',['yên']='iɜŋ',['yêng']='iɜŋ',['yêp']='iɜʔp̚',['yêt']='iɜʔk̚',['yêu']='iɜw'}))
				else
					ipa[i] = (ipa[i] .. mw.ustring.gsub(finaldetone[i],'[aăâeêioôơuưy][aâăeêioôơuưy]?[aêiuy]?[mncptk]?[hg]?',{['a']='aː',['ac']='aːʔk̚',['ach']='ɐʔt̚',['ai']='aːj',['am']='aːm',['an']='aːŋ',['ang']='aːŋ',['anh']='ɐn',['ao']='aːw',['ap']='aːʔp̚',['at']='aːʔk̚',['au']='ɐw',['ay']='ɐj',['ăc']='ɐʔk̚',['ăm']='ɐm',['ăn']='ɐŋ',['ăng']='ɐŋ',['ăp']='ɐʔp̚',['ăt']='ɐʔk̚',['â']='ɜ',['âc']='ɜʔk̚',['âm']='ɜm',['ân']='ɜŋ',['âng']='ɜŋ',['ânh']='ɜn',['âp']='ɜʔp̚',['ât']='ɜʔk̚',['âu']='ɜw',['ây']='ɜj',['e']='ɛ',['ec']='ɛʔk̚',['em']='ɛm',['en']='ɛŋ',['eng']='ɛŋ',['eo']='ɛw',['ep']='ɛʔp̚',['et']='ɛʔk̚',['ê']='ej',['êc']='eʔk̚',['êch']='ɜːʔt̚',['êm']='em',['ên']='ɜːn',['êng']='eŋ',['ênh']='ɜːn',['êp']='eʔp̚',['êt']='ɜːʔt̚',['êu']='ew',['i']='ɪj',['ia']='iɜ',['ich']='ɨ̞̠ʔt̚',['iêc']='iɜʔk̚',['iêm']='iɜm',['iên']='iɜŋ',['iêng']='iɜŋ',['iêp']='iɜʔp̚',['iêt']='iɜʔk̚',['iêu']='iɜw',['im']='im',['ym']='im',['in']='ɨ̞̠n',['inh']='ɨ̞̠n',['ip']='iʔp̚',['it']='ɨ̞̠ʔt̚',['iu']='iw',['o']='ɔ',['oa']='waː',['oac']='waːʔk̚',['oach']='wɐʔt̚',['oai']='waːj',['oam']='waːm',['oan']='waːŋ',['oang']='waːŋ',['oanh']='wɐn',['oao']='waːw',['oap']='waːʔp̚',['oat']='waːʔk̚',['oay']='wa(ː)j',['oăc']='wɐʔk̚',['oăm']='wɐm',['oăn']='wɐŋ',['oăng']='wɐŋ',['oăt']='wɐʔk̚',['oc']='a(ː)wʔk͡p̚',['oe']='wɛ',['oen']='wɛŋ',['oeo']='wɛw',['oet']='wɛʔk̚',['oi']='ɔj',['om']='ɔm',['on']='ɔŋ',['ong']='ɐwŋ͡m',['oong']='ɔŋ',['op']='ɔʔp̚',['ot']='ɔʔk̚',['ô']='ow',['ôc']='ɜwʔk͡p̚',['ôi']='oj',['ôm']='om',['ôn']='oŋ',['ông']='ɜwŋ͡m',['ôông']='oŋ',['ôp']='oʔp̚',['ôt']='oʔk̚',['ơ']='əːɰ',['ơi']='əːj',['ơm']='əːm',['ơn']='əːŋ',['ơng']='əːŋ',['ơp']='əːʔp̚',['ơt']='əːʔk̚',['ơu']='əːw',['u']='ʊw',['ua']='waː',['uac']='waːʔk̚',['uach']='wɐt̚',['uai']='waːj',['uan']='waːŋ',['uang']='waːŋ',['uanh']='wɐn',['uao']='waːw',['uat']='waːʔk̚',['uau']='wa(ː)w',['uay']='wa(ː)j',['uăc']='wɐʔk̚',['uăm']='wɐm',['uăn']='wɐŋ',['uăng']='wɐŋ',['uăp']='wɐʔp̚',['uăt']='wɐʔk̚',['uâc']='wɜʔk̚',['uân']='wɜŋ',['uâng']='wɜŋ',['uât']='wɜʔk̚',['uây']='wɜj',['uc']='uwʔk͡p̚',['ue']='wɛ',['uen']='wɛŋ',['ueo']='wɛw',['uep']='wɛʔp̚',['uet']='wɛʔt̚',['uê']='wej',['uêch']='wɜːʔt̚',['uên']='wɜːn',['uênh']='wɜːn',['uêt']='wɜːʔt̚',['uêu']='wew',['ui']='uj',['uit']='wiʔt̚',['um']='um',['un']='uŋ͡m',['ung']='uwŋ͡m',['unh']='uwn',['uôc']='uɜʔk̚',['uôi']='uj',['uôm']='uɜm',['uôn']='uɜŋ',['uông']='uɜŋ',['uôt']='uɜʔk̚',['uơ']='wəː',['uơi']='wɜj',['uơn']='wɜŋ',['uơt']='wɜʔk̚',['up']='uʔp̚',['ut']='uʔk͡p̚',['uy']='wi',['uya']='wiɜ',['uych']='wɨ̞̠ʔt̚',['uich']='wɨ̞̠ʔt̚',['uyêc']='wiɜʔk̚',['uyên']='wiɜŋ',['uyênh']='wɜn',['uyêt']='wiɜʔk̚',['uynh']='wɨ̞̠n',['uyt']='wɨ̞̠ʔt̚',['uyu']='wiw',['ư']='ɨ̞̠ɰ',['ưa']='ɨ̞̠ɜ',['ưc']='ɨ̞̠ʔk̚',['ưi']='ɨ̞̠j',['ưn']='ɨ̞̠ŋ',['ưng']='ɨ̞̠ŋ',['ươc']='ɨ̞̠ɜʔk̚',['ươi']='ɨ̞̠ɜj',['ươm']='ɨ̞̠ɜm',['ươn']='ɨ̞̠ɜŋ',['ương']='ɨ̞̠ɜŋ',['ươp']='ɨ̞̠ɜʔp̚',['ươt']='ɨ̞̠ɜʔk̚',['ươu']='ɨ̞̠ɜw',['ưt']='ɨ̞̠ʔk̚',['ưu']='ɨ̞̠w',['wui']='wuj',['y']='ɪj',['yêc']='iɜʔk̚',['yêm']='iɜm',['yên']='iɜŋ',['yêng']='iɜŋ',['yêp']='iɜʔp̚',['yêt']='iɜʔk̚',['yêu']='iɜw'}))
				end
			else
				if mw.ustring.gsub(initial[i],'[tcxsdl][hr]?',{['th']='',['ch']='',['tr']='',['x']='',['s']='',['d']='',['l']='',['t']=''}) == '' then
					ipa[i] = (ipa[i] .. mw.ustring.gsub(finaldetone[i],'[aăâeêioôơuưy][aâăeêioôơuưy]?[aêiuy]?[mncptk]?[hg]?',{['a']='aː',['ac']='aːʔk̚',['ach']='ɐʔt̚',['ai']='aːj',['am']='aːm',['an']='aːŋ',['ang']='aːŋ',['anh']='ɐn',['ao']='aːw',['ap']='aːʔp̚',['at']='aːʔk̚',['au']='ɐw',['ay']='ɐj',['ăc']='ɐʔk̚',['ăm']='ɐm',['ăn']='ɐŋ',['ăng']='ɐŋ',['ăp']='ɐʔp̚',['ăt']='ɐʔk̚',['â']='ɜ',['âc']='ɜʔk̚',['âm']='ɜm',['ân']='ɜŋ',['âng']='ɜŋ',['ânh']='ɜn',['âp']='ɜʔp̚',['ât']='ɜʔk̚',['âu']='ɜw',['ây']='ɜj',['e']='ɛ',['ec']='ɛʔk̚',['em']='ɛm',['en']='ɛŋ',['eng']='ɛŋ',['eo']='ɛw',['ep']='ɛʔp̚',['et']='ɛʔk̚',['ê']='ej',['êc']='eʔk̚',['êch']='ɜːʔt̚',['êm']='em',['ên']='ɜːn',['êng']='eŋ',['ênh']='ɜːn',['êp']='eʔp̚',['êt']='ɜːʔt̚',['êu']='ew',['i']='ɪj',['ia']='iɜ',['ich']='ɨ̞̠ʔt̚',['iêc']='iɜʔk̚',['iêm']='iɜm',['iên']='iɜŋ',['iêng']='iɜŋ',['iêp']='iɜʔp̚',['iêt']='iɜʔk̚',['iêu']='iɜw',['im']='im',['ym']='im',['in']='ɨ̞̠n',['inh']='ɨ̞̠n',['ip']='iʔp̚',['it']='ɨ̞̠ʔt̚',['iu']='iw',['o']='ɔ',['oa']='<sup>(</sup>ʷ<sup>)</sup>aː',['oac']='<sup>(</sup>ʷ<sup>)</sup>aːʔk̚',['oach']='<sup>(</sup>ʷ<sup>)</sup>ɐʔt̚',['oai']='<sup>(</sup>ʷ<sup>)</sup>aːj',['oam']='<sup>(</sup>ʷ<sup>)</sup>aːm',['oan']='<sup>(</sup>ʷ<sup>)</sup>aːŋ',['oang']='<sup>(</sup>ʷ<sup>)</sup>aːŋ',['oanh']='<sup>(</sup>ʷ<sup>)</sup>ɐn',['oao']='<sup>(</sup>ʷ<sup>)</sup>aːw',['oap']='<sup>(</sup>ʷ<sup>)</sup>aːʔp̚',['oat']='<sup>(</sup>ʷ<sup>)</sup>aːʔk̚',['oay']='<sup>(</sup>ʷ<sup>)</sup>a(ː)j',['oăc']='<sup>(</sup>ʷ<sup>)</sup>ɐʔk̚',['oăm']='<sup>(</sup>ʷ<sup>)</sup>ɐm',['oăn']='<sup>(</sup>ʷ<sup>)</sup>ɐŋ',['oăng']='<sup>(</sup>ʷ<sup>)</sup>ɐŋ',['oăt']='<sup>(</sup>ʷ<sup>)</sup>ɐʔk̚',['oc']='a(ː)wʔk͡p̚',['oe']='<sup>(</sup>ʷ<sup>)</sup>ɛ',['oen']='<sup>(</sup>ʷ<sup>)</sup>ɛŋ',['oeo']='<sup>(</sup>ʷ<sup>)</sup>ɛw',['oet']='<sup>(</sup>ʷ<sup>)</sup>ɛʔk̚',['oi']='ɔj',['om']='ɔm',['on']='ɔŋ',['ong']='ɐwŋ͡m',['oong']='ɔŋ',['op']='ɔʔp̚',['ot']='ɔʔk̚',['ô']='ow',['ôc']='ɜwʔk͡p̚',['ôi']='oj',['ôm']='om',['ôn']='oŋ',['ông']='ɜwŋ͡m',['ôông']='oŋ',['ôp']='oʔp̚',['ôt']='oʔk̚',['ơ']='əːɰ',['ơi']='əːj',['ơm']='əːm',['ơn']='əːŋ',['ơng']='əːŋ',['ơp']='əːʔp̚',['ơt']='əːʔk̚',['ơu']='əːw',['u']='ʊw',['ua']='<sup>(</sup>ʷ<sup>)</sup>ɜ',['uac']='<sup>(</sup>ʷ<sup>)</sup>aːʔk̚',['uach']='<sup>(</sup>ʷ<sup>)</sup>ɐt̚',['uai']='<sup>(</sup>ʷ<sup>)</sup>aːj',['uan']='<sup>(</sup>ʷ<sup>)</sup>aːŋ',['uang']='<sup>(</sup>ʷ<sup>)</sup>aːŋ',['uanh']='<sup>(</sup>ʷ<sup>)</sup>ɐn',['uao']='<sup>(</sup>ʷ<sup>)</sup>aːw',['uat']='<sup>(</sup>ʷ<sup>)</sup>aːʔk̚',['uau']='<sup>(</sup>ʷ<sup>)</sup>a(ː)w',['uay']='<sup>(</sup>ʷ<sup>)</sup>a(ː)j',['uăc']='<sup>(</sup>ʷ<sup>)</sup>ɐʔk̚',['uăm']='<sup>(</sup>ʷ<sup>)</sup>ɐm',['uăn']='<sup>(</sup>ʷ<sup>)</sup>ɐŋ',['uăng']='<sup>(</sup>ʷ<sup>)</sup>ɐŋ',['uăp']='<sup>(</sup>ʷ<sup>)</sup>ɐʔp̚',['uăt']='<sup>(</sup>ʷ<sup>)</sup>ɐʔk̚',['uâc']='<sup>(</sup>ʷ<sup>)</sup>ɜʔk̚',['uân']='<sup>(</sup>ʷ<sup>)</sup>ɜŋ',['uâng']='<sup>(</sup>ʷ<sup>)</sup>ɜŋ',['uât']='<sup>(</sup>ʷ<sup>)</sup>ɜʔk̚',['uây']='<sup>(</sup>ʷ<sup>)</sup>ɜj',['uc']='uwʔk͡p̚',['ue']='<sup>(</sup>ʷ<sup>)</sup>ɛ',['uen']='<sup>(</sup>ʷ<sup>)</sup>ɛŋ',['ueo']='<sup>(</sup>ʷ<sup>)</sup>ɛw',['uep']='<sup>(</sup>ʷ<sup>)</sup>ɛʔp̚',['uet']='<sup>(</sup>ʷ<sup>)</sup>ɛʔt̚',['uê']='<sup>(</sup>ʷ<sup>)</sup>ej',['uêch']='<sup>(</sup>ʷ<sup>)</sup>ɜːʔt̚',['uên']='<sup>(</sup>ʷ<sup>)</sup>ɜːn',['uênh']='<sup>(</sup>ʷ<sup>)</sup>ɜːn',['uêt']='<sup>(</sup>ʷ<sup>)</sup>ɜːʔt̚',['uêu']='<sup>(</sup>ʷ<sup>)</sup>ew',['ui']='uj',['uit']='<sup>(</sup>ʷ<sup>)</sup>iʔt̚',['um']='um',['un']='uŋ͡m',['ung']='uwŋ͡m',['unh']='uwn',['uôc']='uɜʔk̚',['uôi']='uj',['uôm']='uɜm',['uôn']='uɜŋ',['uông']='uɜŋ',['uôt']='uɜʔk̚',['uơ']='<sup>(</sup>ʷ<sup>)</sup>əː',['uơi']='<sup>(</sup>ʷ<sup>)</sup>ɜj',['uơn']='<sup>(</sup>ʷ<sup>)</sup>ɜŋ',['uơt']='<sup>(</sup>ʷ<sup>)</sup>ɜʔk̚',['up']='uʔp̚',['ut']='uʔk͡p̚',['uy']='<sup>(</sup>ʷ<sup>)</sup>i',['uya']='<sup>(</sup>ʷ<sup>)</sup>iɜ',['uych']='<sup>(</sup>ʷ<sup>)</sup>ɨ̞̠ʔt̚',['uich']='<sup>(</sup>ʷ<sup>)</sup>ɨ̞̠ʔt̚',['uyêc']='<sup>(</sup>ʷ<sup>)</sup>iɜʔk̚',['uyên']='<sup>(</sup>ʷ<sup>)</sup>iɜŋ',['uyênh']='<sup>(</sup>ʷ<sup>)</sup>ɜn',['uyêt']='<sup>(</sup>ʷ<sup>)</sup>iɜʔk̚',['uynh']='<sup>(</sup>ʷ<sup>)</sup>ɨ̞̠n',['uyt']='<sup>(</sup>ʷ<sup>)</sup>ɨ̞̠ʔt̚',['uyu']='<sup>(</sup>ʷ<sup>)</sup>iw',['ư']='ɨ̞̠ɰ',['ưa']='ɨ̞̠ɜ',['ưc']='ɨ̞̠ʔk̚',['ưi']='ɨ̞̠j',['ưn']='ɨ̞̠ŋ',['ưng']='ɨ̞̠ŋ',['ươc']='ɨ̞̠ɜʔk̚',['ươi']='ɨ̞̠ɜj',['ươm']='ɨ̞̠ɜm',['ươn']='ɨ̞̠ɜŋ',['ương']='ɨ̞̠ɜŋ',['ươp']='ɨ̞̠ɜʔp̚',['ươt']='ɨ̞̠ɜʔk̚',['ươu']='ɨ̞̠ɜw',['ưt']='ɨ̞̠ʔk̚',['ưu']='ɨ̞̠w',['wui']='<sup>(</sup>ʷ<sup>)</sup>uj',['y']='ɪj',['yêc']='iɜʔk̚',['yêm']='iɜm',['yên']='iɜŋ',['yêng']='iɜŋ',['yêp']='iɜʔp̚',['yêt']='iɜʔk̚',['yêu']='iɜw'}))
				else
					ipa[i] = (ipa[i] .. mw.ustring.gsub(finaldetone[i],'[aăâeêioôơuưy][aâăeêioôơuưy]?[aêiuy]?[mncptk]?[hg]?',{['a']='aː',['ac']='aːʔk̚',['ach']='ɐʔt̚',['ai']='aːj',['am']='aːm',['an']='aːŋ',['ang']='aːŋ',['anh']='ɐn',['ao']='aːw',['ap']='aːʔp̚',['at']='aːʔk̚',['au']='ɐw',['ay']='ɐj',['ăc']='ɐʔk̚',['ăm']='ɐm',['ăn']='ɐŋ',['ăng']='ɐŋ',['ăp']='ɐʔp̚',['ăt']='ɐʔk̚',['â']='ɜ',['âc']='ɜʔk̚',['âm']='ɜm',['ân']='ɜŋ',['âng']='ɜŋ',['ânh']='ɜn',['âp']='ɜʔp̚',['ât']='ɜʔk̚',['âu']='ɜw',['ây']='ɜj',['e']='ɛ',['ec']='ɛʔk̚',['em']='ɛm',['en']='ɛŋ',['eng']='ɛŋ',['eo']='ɛw',['ep']='ɛʔp̚',['et']='ɛʔk̚',['ê']='ej',['êc']='eʔk̚',['êch']='ɜːʔt̚',['êm']='em',['ên']='ɜːn',['êng']='eŋ',['ênh']='ɜːn',['êp']='eʔp̚',['êt']='ɜːʔt̚',['êu']='ew',['i']='ɪj',['ia']='iɜ',['ich']='ɨ̞̠ʔt̚',['iêc']='iɜʔk̚',['iêm']='iɜm',['iên']='iɜŋ',['iêng']='iɜŋ',['iêp']='iɜʔp̚',['iêt']='iɜʔk̚',['iêu']='iɜw',['im']='im',['ym']='im',['in']='ɨ̞̠n',['inh']='ɨ̞̠n',['ip']='iʔp̚',['it']='ɨ̞̠ʔt̚',['iu']='iw',['o']='ɔ',['oa']='waː',['oac']='waːʔk̚',['oach']='wɐʔt̚',['oai']='waːj',['oam']='waːm',['oan']='waːŋ',['oang']='waːŋ',['oanh']='wɐn',['oao']='waːw',['oap']='waːʔp̚',['oat']='waːʔk̚',['oay']='wa(ː)j',['oăc']='wɐʔk̚',['oăm']='wɐm',['oăn']='wɐŋ',['oăng']='wɐŋ',['oăt']='wɐʔk̚',['oc']='a(ː)wʔk͡p̚',['oe']='wɛ',['oen']='wɛŋ',['oeo']='wɛw',['oet']='wɛʔk̚',['oi']='ɔj',['om']='ɔm',['on']='ɔŋ',['ong']='ɐwŋ͡m',['oong']='ɔŋ',['op']='ɔʔp̚',['ot']='ɔʔk̚',['ô']='ow',['ôc']='ɜwʔk͡p̚',['ôi']='oj',['ôm']='om',['ôn']='oŋ',['ông']='ɜwŋ͡m',['ôông']='oŋ',['ôp']='oʔp̚',['ôt']='oʔk̚',['ơ']='əːɰ',['ơi']='əːj',['ơm']='əːm',['ơn']='əːŋ',['ơng']='əːŋ',['ơp']='əːʔp̚',['ơt']='əːʔk̚',['ơu']='əːw',['u']='ʊw',['ua']='wɜ',['uac']='waːʔk̚',['uach']='wɐt̚',['uai']='waːj',['uan']='waːŋ',['uang']='waːŋ',['uanh']='wɐn',['uao']='waːw',['uat']='waːʔk̚',['uau']='wa(ː)w',['uay']='wa(ː)j',['uăc']='wɐʔk̚',['uăm']='wɐm',['uăn']='wɐŋ',['uăng']='wɐŋ',['uăp']='wɐʔp̚',['uăt']='wɐʔk̚',['uâc']='wɜʔk̚',['uân']='wɜŋ',['uâng']='wɜŋ',['uât']='wɜʔk̚',['uây']='wɜj',['uc']='uwʔk͡p̚',['ue']='wɛ',['uen']='wɛŋ',['ueo']='wɛw',['uep']='wɛʔp̚',['uet']='wɛʔt̚',['uê']='wej',['uêch']='wɜːʔt̚',['uên']='wɜːn',['uênh']='wɜːn',['uêt']='wɜːʔt̚',['uêu']='wew',['ui']='uj',['uit']='wiʔt̚',['um']='um',['un']='uŋ͡m',['ung']='uwŋ͡m',['unh']='uwn',['uôc']='uɜʔk̚',['uôi']='uj',['uôm']='uɜm',['uôn']='uɜŋ',['uông']='uɜŋ',['uôt']='uɜʔk̚',['uơ']='wəː',['uơi']='wɜj',['uơn']='wɜŋ',['uơt']='wɜʔk̚',['up']='uʔp̚',['ut']='uʔk͡p̚',['uy']='wi',['uya']='wiɜ',['uych']='wɨ̞̠ʔt̚',['uich']='wɨ̞̠ʔt̚',['uyêc']='wiɜʔk̚',['uyên']='wiɜŋ',['uyênh']='wɜn',['uyêt']='wiɜʔk̚',['uynh']='wɨ̞̠n',['uyt']='wɨ̞̠ʔt̚',['uyu']='wiw',['ư']='ɨ̞̠ɰ',['ưa']='ɨ̞̠ɜ',['ưc']='ɨ̞̠ʔk̚',['ưi']='ɨ̞̠j',['ưn']='ɨ̞̠ŋ',['ưng']='ɨ̞̠ŋ',['ươc']='ɨ̞̠ɜʔk̚',['ươi']='ɨ̞̠ɜj',['ươm']='ɨ̞̠ɜm',['ươn']='ɨ̞̠ɜŋ',['ương']='ɨ̞̠ɜŋ',['ươp']='ɨ̞̠ɜʔp̚',['ươt']='ɨ̞̠ɜʔk̚',['ươu']='ɨ̞̠ɜw',['ưt']='ɨ̞̠ʔk̚',['ưu']='ɨ̞̠w',['wui']='wuj',['y']='ɪj',['yêc']='iɜʔk̚',['yêm']='iɜm',['yên']='iɜŋ',['yêng']='iɜŋ',['yêp']='iɜʔp̚',['yêt']='iɜʔk̚',['yêu']='iɜw'}))
				end
			end
			if tone[i] == 1 then
				ipa[i] = (ipa[i] .. '˧˥')
			elseif tone[i] == 2 then
				ipa[i] = (ipa[i] .. '˨˩')
			elseif tone[i] == 3 then
				ipa[i] = (ipa[i] .. '˦ˀ˥')
			elseif tone[i] == 4 then
				ipa[i] = (ipa[i] .. '˨˦')
			elseif tone[i] == 5 then
				ipa[i] = (ipa[i] .. '˨˦')
			elseif tone[i] == 6 then
				ipa[i] = (ipa[i] .. '˨ˀ˧ʔ')
			end
		end
	end
	return table.concat(ipa," ")
end
 
return export