Spaces:
Runtime error
Runtime error
import unittest | |
from utils.thai_word import ThaiWord | |
class TestThaiWord(unittest.TestCase): | |
def setUp(self) -> None: | |
self.thw = ThaiWord() | |
def test_pretty_text_to_numeric(self): | |
self.assertEqual( | |
self.thw.pretty(['ฮา','โหล','หนึ่ง','สอง','สาม','สี่']), | |
'ฮาโหล1234', | |
'should convert single word number in thai to numeric' | |
) | |
def test_pretty_long_words_to_numeric(self): | |
self.assertEqual( | |
self.thw.pretty([ | |
'ปี','นี้','สอง','พัน','ห้า','ร้อย','หก','สิบ','เจ็ด','นะ', | |
' ', | |
'ปี','หน้า','ก็','สอง','พัน','ห้า','ร้อย','หก','สิบ','แปด' | |
]), | |
'ปีนี้2567นะ ปีหน้าก็2568', | |
'should convert full-words number in thai to numeric in long words (case1)' | |
) | |
self.assertEqual( | |
self.thw.pretty([ | |
'อืม', ' ', 'อยาก', 'ได้', 'ราย', 'ได้', 'ยี่', 'สิบ', | |
'เอ็ดล้าน', 'แบบ', 'เข้า', 'บ้าง', ' ', 'ทำ', 'ยัง', 'ไง', 'ดี' | |
]), | |
'อืม อยากได้รายได้21000000แบบเข้าบ้าง ทำยังไงดี', | |
'should convert full-words number in thai to numeric in long words (case2)' | |
) | |
self.assertEqual( | |
self.thw.pretty([ | |
'อืม',' ','อยาก','ได้','ราย','ได้','ยี่สิบ','เอ็ด','ล้าน', | |
'แบบ', 'ร้าน','พร้อม','ทำ','ยัง','ไง','ดี' | |
]), | |
'อืม อยากได้รายได้21000000แบบร้านพร้อมทำยังไงดี', | |
'should convert full-words number in thai to numeric in long words (case3)' | |
) | |
def test_pretty_word11_to_numeric(self): | |
self.assertEqual( | |
self.thw.pretty(['ซื้อ','มา','สิบ','เอ็ด','บาท']), | |
'ซื้อมา11บาท', | |
'should correct specific numeric "สิบ" and "เอ็ด"' | |
) | |
self.assertEqual( | |
self.thw.pretty(['ซื้อ','มา','สิบเอ็ด','บาท']), | |
'ซื้อมา11บาท', | |
'should correct specific numeric "สิบเอ็ด"' | |
) | |
def test_pretty_word2x_to_numeric(self): | |
self.assertEqual( | |
self.thw.pretty(['ซื้อ','มา','ยี่','สิบ','ห้า','บาท']), | |
'ซื้อมา25บาท', | |
'should correct specific numeric "ยี่" and "สิบ"' | |
) | |
self.assertEqual( | |
self.thw.pretty(['ซื้อ','มา','ยี่สิบ','ห้า','บาท']), | |
'ซื้อมา25บาท', | |
'should correct specific numeric "ยี่สิบ"' | |
) | |
def tearDown(self) -> None: | |
self.thw = None |