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
54from 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"""
0 commit comments