Skip to content

Commit 3d324e3

Browse files
committed
Fixed pep8
1 parent dd2ddaa commit 3d324e3

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

pythainlp/morpheme/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
"""
66
PyThaiNLP morpheme
77
"""
8-
from pythainlp.morpheme.word_formation import nighit
8+
from pythainlp.morpheme.word_formation import nighit

pythainlp/morpheme/word_formation.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# -*- coding: utf-8 -*-
22
# SPDX-FileCopyrightText: Copyright 2016-2024 PyThaiNLP Project
33
# SPDX-License-Identifier: Apache-2.0
4-
from pythainlp.transliterate import pronunciate
54
from pythainlp import thai_consonants
65

76

8-
def nighit(w1: str,w2: str)->str:
7+
def nighit(w1: str, w2: str) -> str:
98
"""
109
Nighit (นิคหิต or ํ ) is the niggahita in Thai language for create new \
1110
words from Pali language in Thai.
@@ -29,25 +28,25 @@ def nighit(w1: str,w2: str)->str:
2928
assert nighit("สํ","ปทา")=="สัมปทา"
3029
assert nighit("สํ","โยค")=="สังโยค"
3130
"""
32-
if not str(w1).endswith('ํ') and len(w1)!=2:
31+
if not str(w1).endswith('ํ') and len(w1) != 2:
3332
raise NotImplementedError(f"The function doesn't support {w1}.")
3433
list_w1 = list(w1)
3534
list_w2 = list(w2)
3635
newword = list()
3736
newword.append(list_w1[0])
3837
newword.append("ั")
3938
consonant_start = [i for i in list_w2 if i in set(thai_consonants)][0]
40-
if consonant_start in ["ก","ช","ค","ข","ง"]:
39+
if consonant_start in ["ก", "ช", "ค", "ข", "ง"]:
4140
newword.append("ง")
42-
elif consonant_start in ["จ","ฉ","ช","ฌ"]:
41+
elif consonant_start in ["จ", "ฉ", "ช", "ฌ"]:
4342
newword.append("ญ")
44-
elif consonant_start in ["ฎ","ฐ","ฑ","ณ"]:
43+
elif consonant_start in ["ฎ", "ฐ", "ฑ", "ณ"]:
4544
newword.append("ณ")
46-
elif consonant_start in ["ด","ถ","ท","ธ","น"]:
45+
elif consonant_start in ["ด", "ถ", "ท", "ธ", "น"]:
4746
newword.append("น")
48-
elif consonant_start in ["ป","ผ","พ","ภ"]:
47+
elif consonant_start in ["ป", "ผ", "พ", "ภ"]:
4948
newword.append("ม")
50-
elif consonant_start in ["ย","ร","ล","ฬ","ว","ศ","ษ","ส","ห"]:
49+
elif consonant_start in ["ย", "ร", "ล", "ฬ", "ว", "ศ", "ษ", "ส", "ห"]:
5150
newword.append("ง")
5251
else:
5352
raise NotImplementedError(f"""

tests/test_morpheme.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
class TestMorphemePackage(unittest.TestCase):
1010
def test_nighit(self):
11-
self.assertEqual(nighit("สํ","คีต"), "สังคีต")
12-
self.assertEqual(nighit("สํ","จร"), "สัญจร")
13-
self.assertEqual(nighit("สํ","ฐาน"), "สัณฐาน")
14-
self.assertEqual(nighit("สํ","นิษฐาน"), "สันนิษฐาน")
15-
self.assertEqual(nighit("สํ","ปทา"), "สัมปทา")
16-
self.assertEqual(nighit("สํ","โยค"), "สังโยค")
11+
self.assertEqual(nighit("สํ", "คีต"), "สังคีต")
12+
self.assertEqual(nighit("สํ", "จร"), "สัญจร")
13+
self.assertEqual(nighit("สํ", "ฐาน"), "สัณฐาน")
14+
self.assertEqual(nighit("สํ", "นิษฐาน"), "สันนิษฐาน")
15+
self.assertEqual(nighit("สํ", "ปทา"), "สัมปทา")
16+
self.assertEqual(nighit("สํ", "โยค"), "สังโยค")

0 commit comments

Comments
 (0)