Skip to content

Commit 22ead5a

Browse files
committed
Move tone and khuap_klam test to compact suite
1 parent e6d9edd commit 22ead5a

2 files changed

Lines changed: 17 additions & 44 deletions

File tree

tests/compact/testc_util.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,17 @@ def test_spell_word(self):
2222
self.assertEqual(
2323
spell_word("คนดี"), ["คอ", "นอ", "คน", "ดอ", "อี", "ดี", "คนดี"]
2424
)
25+
result = spell_word("คน")
26+
self.assertIsInstance(result, list)
27+
self.assertIn("คน", result)
28+
2529
# Edge cases: None and empty string
2630
self.assertEqual(spell_word(None), [])
2731
self.assertEqual(spell_word(""), [])
2832

33+
# multi-syllable: last element is the full word
34+
result_multi = spell_word("คนดี")
35+
self.assertEqual(result_multi[-1], "คนดี")
2936

3037
class UtilTestCaseC(unittest.TestCase):
3138
def test_rhyme(self):
@@ -37,6 +44,14 @@ def test_thai_word_tone_detector(self):
3744
self.assertEqual(
3845
thai_word_tone_detector("ราคา"), [("รา", "m"), ("คา", "m")]
3946
)
47+
result = thai_word_tone_detector("คนดี")
48+
self.assertIsInstance(result, list)
49+
valid_tones = {"l", "m", "h", "r", "f", ""}
50+
for syllable, tone in result:
51+
self.assertIsInstance(syllable, str)
52+
self.assertIn(tone, valid_tones)
53+
self.assertIsInstance(thai_word_tone_detector("มือถือ"), list)
54+
4055
# Edge cases: None and empty string
4156
self.assertEqual(thai_word_tone_detector(None), [])
4257
self.assertEqual(thai_word_tone_detector(""), [])
@@ -63,3 +78,5 @@ def test_check_khuap_klam(self):
6378

6479
# Edge cases: empty string returns None
6580
self.assertIsNone(check_khuap_klam(""))
81+
for word in ["กลม", "จริง", "ตา"]:
82+
self.assertIn(check_khuap_klam(word), (True, False, None))

tests/core/test_util.py

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
analyze_thai_text,
1818
arabic_digit_to_thai_digit,
1919
bahttext,
20-
check_khuap_klam,
2120
collate,
2221
convert_years,
2322
count_thai_chars,
@@ -50,7 +49,6 @@
5049
reorder_vowels,
5150
sound_syllable,
5251
spell_syllable,
53-
spell_word,
5452
spelling,
5553
syllable_length,
5654
syllable_open_close_detector,
@@ -64,7 +62,6 @@
6462
thai_strftime,
6563
thai_strptime,
6664
thai_to_eng,
67-
thai_word_tone_detector,
6865
thaiword_to_date,
6966
thaiword_to_num,
7067
thaiword_to_time,
@@ -1058,24 +1055,6 @@ def test_analyze_thai_text(self):
10581055
{'สระ เอ': 1, 'ล': 1, 'ไม้เอก': 1, 'น': 1}
10591056
)
10601057

1061-
# ### pythainlp.util.khuap_klam
1062-
1063-
def test_check_khuap_klam(self):
1064-
# true consonant clusters (คำควบกล้ำแท้)
1065-
self.assertTrue(check_khuap_klam("กราบ"))
1066-
self.assertTrue(check_khuap_klam("ปลา"))
1067-
self.assertTrue(check_khuap_klam("เพราะ"))
1068-
# false consonant clusters (คำควบกล้ำไม่แท้)
1069-
self.assertFalse(check_khuap_klam("จริง"))
1070-
self.assertFalse(check_khuap_klam("ทราย"))
1071-
# not a cluster
1072-
self.assertIsNone(check_khuap_klam("แม่"))
1073-
self.assertIsNone(check_khuap_klam("ตา"))
1074-
# edge cases
1075-
self.assertIsNone(check_khuap_klam(""))
1076-
for word in ["กลม", "จริง", "ตา"]:
1077-
self.assertIn(check_khuap_klam(word), (True, False, None))
1078-
10791058
# ### pythainlp.util.pronounce
10801059

10811060
def test_thai_consonant_to_spelling(self):
@@ -1107,29 +1086,6 @@ def test_spell_syllable(self):
11071086
self.assertGreater(len(result_kon), 0)
11081087
self.assertIn("คน", result_kon)
11091088

1110-
def test_spell_word(self):
1111-
self.assertEqual(spell_word(None), [])
1112-
self.assertEqual(spell_word(""), [])
1113-
result = spell_word("คน")
1114-
self.assertIsInstance(result, list)
1115-
self.assertIn("คน", result)
1116-
# multi-syllable: last element is the full word
1117-
result_multi = spell_word("คนดี")
1118-
self.assertEqual(result_multi[-1], "คนดี")
1119-
1120-
# ### pythainlp.util.thai – thai_word_tone_detector
1121-
1122-
def test_thai_word_tone_detector(self):
1123-
self.assertEqual(thai_word_tone_detector(None), [])
1124-
self.assertEqual(thai_word_tone_detector(""), [])
1125-
result = thai_word_tone_detector("คนดี")
1126-
self.assertIsInstance(result, list)
1127-
valid_tones = {"l", "m", "h", "r", "f", ""}
1128-
for syllable, tone in result:
1129-
self.assertIsInstance(syllable, str)
1130-
self.assertIn(tone, valid_tones)
1131-
self.assertIsInstance(thai_word_tone_detector("มือถือ"), list)
1132-
11331089
# ### pythainlp.util.normalize – remove_repeat_vowels,
11341090
# remove_spaces_before_marks, reorder_vowels
11351091

0 commit comments

Comments
 (0)