forked from PyThaiNLP/pythainlp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestx_spell.py
67 lines (52 loc) · 2.21 KB
/
testx_spell.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# -*- coding: utf-8 -*-
# SPDX-FileCopyrightText: 2016-2024 PyThaiNLP Project
# SPDX-License-Identifier: Apache-2.0
import unittest
from pythainlp.spell import (
correct,
correct_sent,
spell,
spell_sent,
symspellpy,
)
from ..core.test_spell import SENT_TOKS
class SpellTestCaseX(unittest.TestCase):
def test_spell(self):
result = spell("เน้ร", engine="phunspell")
self.assertIsInstance(result, list)
self.assertGreater(len(result), 0)
result = spell("เกสมร์", engine="phunspell")
self.assertIsInstance(result, list)
self.assertGreater(len(result), 0)
result = spell("เน้ร", engine="symspellpy")
self.assertIsInstance(result, list)
self.assertGreater(len(result), 0)
result = spell("เกสมร์", engine="symspellpy")
self.assertIsInstance(result, list)
self.assertGreater(len(result), 0)
result = spell("เน้ร", engine="tltk")
self.assertIsInstance(result, list)
self.assertGreater(len(result), 0)
result = spell("เดก", engine="tltk")
self.assertIsInstance(result, list)
self.assertGreater(len(result), 0)
def test_word_correct(self):
result = correct("ทดสอง", engine="phunspell")
self.assertIsInstance(result, str)
self.assertNotEqual(result, "")
result = correct("ทดสอง", engine="symspellpy")
self.assertIsInstance(result, str)
self.assertNotEqual(result, "")
result = correct("ทดสอง", engine="wanchanberta_thai_grammarly")
self.assertIsInstance(result, str)
self.assertNotEqual(result, "")
def test_spell_sent(self):
self.assertIsNotNone(spell_sent(SENT_TOKS, engine="phunspell"))
self.assertIsNotNone(spell_sent(SENT_TOKS, engine="symspellpy"))
def test_correct_sent(self):
self.assertIsNotNone(correct_sent(SENT_TOKS, engine="phunspell"))
self.assertIsNotNone(correct_sent(SENT_TOKS, engine="symspellpy"))
self.assertIsNotNone(
correct_sent(SENT_TOKS, engine="wanchanberta_thai_grammarly")
)
self.assertIsNotNone(symspellpy.correct_sent(SENT_TOKS))