Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pythainlp/tokenize/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ def sent_tokenize(
result = map_indices_to_words(word_indices, segments)
return result
else:
return [segments]
return segments


def paragraph_tokenize(
Expand Down
12 changes: 0 additions & 12 deletions tests/test_tokenize.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,18 +225,6 @@ def test_sent_tokenize(self):
sent_tokenize("รักน้ำ รักปลา ", engine="whitespace+newline"),
["รักน้ำ", "รักปลา"],
)
self.assertEqual(
sent_tokenize(SENT_1),
SENT_1_TOKS,
)
self.assertEqual(
sent_tokenize(SENT_2),
SENT_2_TOKS,
)
self.assertEqual(
sent_tokenize(SENT_3),
SENT_3_TOKS,
)
self.assertIsNotNone(
sent_tokenize(
SENT_1,
Expand Down
32 changes: 17 additions & 15 deletions tests/testx_tokenize.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,31 +92,35 @@ def testx_sent_tokenize(self):
# Use default engine (crfcut)
self.assertEqual(sent_tokenize(None), [])
self.assertEqual(sent_tokenize(""), [])

self.assertEqual(
sent_tokenize(SENT_1, engine="crfcut"),
sent_tokenize(SENT_1),
SENT_1_TOKS,
)
self.assertEqual(
sent_tokenize(SENT_2, engine="crfcut"),
sent_tokenize(SENT_2),
SENT_2_TOKS,
)
self.assertEqual(
sent_tokenize(SENT_3, engine="crfcut"),
sent_tokenize(SENT_3),
SENT_3_TOKS,
)

self.assertEqual(
sent_tokenize(SENT_1),
sent_tokenize(SENT_1, engine="crfcut"),
SENT_1_TOKS,
)
self.assertEqual(
sent_tokenize(SENT_2),
sent_tokenize(SENT_2, engine="crfcut"),
SENT_2_TOKS,
)
self.assertEqual(
sent_tokenize(SENT_3),
sent_tokenize(SENT_3, engine="crfcut"),
SENT_3_TOKS,
)
self.assertEqual(
sent_tokenize(SENT_4, engine="crfcut"),
[["ผม", "กิน", "ข้าว", " ", "\n", "เธอ", "เล่น", "เกม"]],
)
self.assertIsNotNone(
sent_tokenize(
SENT_1,
Expand All @@ -135,6 +139,7 @@ def testx_sent_tokenize(self):
engine="tltk",
),
)

self.assertIsNotNone(
sent_tokenize(
SENT_1,
Expand All @@ -153,6 +158,11 @@ def testx_sent_tokenize(self):
engine="thaisum",
),
)
self.assertEqual(
sent_tokenize(SENT_4, engine="thaisum"),
[["ผม", "กิน", "ข้าว", " ", "เธอ", "เล่น", "เกม"]],
)

self.assertIsNotNone(
sent_tokenize(
SENT_3,
Expand All @@ -177,14 +187,6 @@ def testx_sent_tokenize(self):
# engine="wtp-large",
# ),
# )
self.assertEqual(
sent_tokenize(SENT_4, engine="crfcut"),
[["ผม", "กิน", "ข้าว", " ", "\n", "เธอ", "เล่น", "เกม"]],
)
self.assertEqual(
sent_tokenize(SENT_4, engine="thaisum"),
[["ผม", "กิน", "ข้าว", " ", "เธอ", "เล่น", "เกม"]],
)

def testx_word_tokenize(self):
self.assertIsNotNone(word_tokenize(TEXT_1, engine="nlpo3"))
Expand Down
Loading