# -*- coding: utf-8 -*-
from __future__ import absolute_import,unicode_literals
from pythainlp.tokenize import word_tokenize
# ถอดเสียงภาษาไทยเป็น Latin
def romanization(data,engine='royin'):
	"""
	:param str data: Thai text to be romanized
	:param str engine: choose between 'royin' , 'pyicu' and 'thai2rom'. 'royin' will romanize according to the standard of Thai Royal Institute. 'pyicu' will romanize according to the Internaitonal Phonetic Alphabet. 'thai2rom' is deep learning thai romanization.
	:return: English (more or less) text that spells out how the Thai text should read.
	"""
	word_list=word_tokenize(data)
	listword=[]
	i=0
	if engine=='royin':
    		from .royin import romanization
	elif engine=='pyicu':
    		from .pyicu import romanization
	elif engine=='thai2rom':
    		from pythainlp.romanization.thai2rom import thai2rom
    		thai=thai2rom()
    		return thai.romanization(data)
	else:
    		raise Exception("error no have engine.")
	while i<len(word_list):
		listword.append(romanization(word_list[i]))
		i+=1
	return ''.join(listword)

@@ -589,39 +589,8 @@
 %22%22%22%0A
-%09word_list=word_tokenize(data)%0A
 %09lis
@@ -602,13 +602,8 @@
 =%5B%5D%0A
-%09i=0%0A
 %09if 
@@ -916,16 +916,61 @@
 gine.%22)%0A
+%09try:%0A%09%09word_list=word_tokenize(data)%0A%09%09i=0%0A%09
 %09while i
@@ -986,16 +986,17 @@
 _list):%0A
+%09
 %09%09listwo
@@ -1039,13 +1039,63 @@
 )%0A%09%09
+%09
 i+=1%0A
+%09except:%0A%09%09listword=%5Bromanization(data)%5D%0A%09%0A%09%09%0A%09%09%0A
 %09ret

fix #176