Commit
·
fdea6f1
1
Parent(s):
0c9becc
Update code
Browse files- routers/soundex.py +2 -2
- routers/spell.py +2 -2
- routers/tokenize.py +3 -3
- routers/util.py +4 -4
routers/soundex.py
CHANGED
@@ -25,9 +25,9 @@ def soundex(word: str, engine: SoundexEngine = "udom83"):
|
|
25 |
## Input
|
26 |
|
27 |
- **word**: A word that want into phonetic code.
|
28 |
-
- **engine**: Soundex Engine (default is udom83
|
29 |
"""
|
30 |
return JSONResponse(
|
31 |
-
|
32 |
media_type="application/json; charset=utf-8",
|
33 |
)
|
|
|
25 |
## Input
|
26 |
|
27 |
- **word**: A word that want into phonetic code.
|
28 |
+
- **engine**: Soundex Engine (default is udom83
|
29 |
"""
|
30 |
return JSONResponse(
|
31 |
+
{"soundex": py_soundex(text=word, engine=engine)},
|
32 |
media_type="application/json; charset=utf-8",
|
33 |
)
|
routers/spell.py
CHANGED
@@ -36,7 +36,7 @@ def correct(word: float, engine: CorrectEngine = "pn"):
|
|
36 |
- **engine**: Correct Engine (default is pn)
|
37 |
"""
|
38 |
return JSONResponse(
|
39 |
-
|
40 |
media_type="application/json; charset=utf-8",
|
41 |
)
|
42 |
|
@@ -52,6 +52,6 @@ def spell(word: float, engine: SpellEngine = "pn"):
|
|
52 |
- **engine**: Spell Engine (default is pn)
|
53 |
"""
|
54 |
return JSONResponse(
|
55 |
-
|
56 |
media_type="application/json; charset=utf-8",
|
57 |
)
|
|
|
36 |
- **engine**: Correct Engine (default is pn)
|
37 |
"""
|
38 |
return JSONResponse(
|
39 |
+
{"word": py_correct(word, engine=engine)},
|
40 |
media_type="application/json; charset=utf-8",
|
41 |
)
|
42 |
|
|
|
52 |
- **engine**: Spell Engine (default is pn)
|
53 |
"""
|
54 |
return JSONResponse(
|
55 |
+
{"word": py_spell(word, engine=engine)},
|
56 |
media_type="application/json; charset=utf-8",
|
57 |
)
|
routers/tokenize.py
CHANGED
@@ -52,7 +52,7 @@ def word_tokenize(text: str, engine: WordTokenizeEngine = "newmm"):
|
|
52 |
- **engine**: Word Tokenize Engine (default is newmm)
|
53 |
"""
|
54 |
return JSONResponse(
|
55 |
-
|
56 |
media_type="application/json; charset=utf-8",
|
57 |
)
|
58 |
|
@@ -68,7 +68,7 @@ def subword_tokenize(text: str, engine: SubwordTokenizeEngine = "tcc"):
|
|
68 |
- **engine**: Sub word Tokenize Engine (default is tcc)
|
69 |
"""
|
70 |
return JSONResponse(
|
71 |
-
|
72 |
media_type="application/json; charset=utf-8",
|
73 |
)
|
74 |
|
@@ -84,6 +84,6 @@ def sent_tokenize(text: str, engine: SentTokenizeEngine = "crfcut"):
|
|
84 |
- **engine**: Sentence Tokenize Engine (default is crfcut)
|
85 |
"""
|
86 |
return JSONResponse(
|
87 |
-
|
88 |
media_type="application/json; charset=utf-8",
|
89 |
)
|
|
|
52 |
- **engine**: Word Tokenize Engine (default is newmm)
|
53 |
"""
|
54 |
return JSONResponse(
|
55 |
+
{"words": py_word_tokenize(text=text, engine=engine)},
|
56 |
media_type="application/json; charset=utf-8",
|
57 |
)
|
58 |
|
|
|
68 |
- **engine**: Sub word Tokenize Engine (default is tcc)
|
69 |
"""
|
70 |
return JSONResponse(
|
71 |
+
{"subwords": py_subword_tokenize(text=text, engine=engine)},
|
72 |
media_type="application/json; charset=utf-8",
|
73 |
)
|
74 |
|
|
|
84 |
- **engine**: Sentence Tokenize Engine (default is crfcut)
|
85 |
"""
|
86 |
return JSONResponse(
|
87 |
+
{"sents": py_sent_tokenize(text=text, engine=engine)},
|
88 |
media_type="application/json; charset=utf-8",
|
89 |
)
|
routers/util.py
CHANGED
@@ -16,7 +16,7 @@ def bahttext(number: float):
|
|
16 |
This api converts a number to Thai text and adds a suffix “บาท” (Baht).
|
17 |
"""
|
18 |
return JSONResponse(
|
19 |
-
|
20 |
media_type="application/json; charset=utf-8",
|
21 |
)
|
22 |
|
@@ -27,7 +27,7 @@ def normalize(text: str):
|
|
27 |
Normalize and clean Thai text
|
28 |
"""
|
29 |
return JSONResponse(
|
30 |
-
|
31 |
media_type="application/json; charset=utf-8",
|
32 |
)
|
33 |
|
@@ -38,7 +38,7 @@ def tone_detector(syllable: str):
|
|
38 |
Thai tone detector for word.
|
39 |
"""
|
40 |
return JSONResponse(
|
41 |
-
|
42 |
media_type="application/json; charset=utf-8",
|
43 |
)
|
44 |
|
@@ -55,6 +55,6 @@ def thaiword_to_num(text: str):
|
|
55 |
- **text**: Spelled-out numerals in Thai scripts
|
56 |
"""
|
57 |
return JSONResponse(
|
58 |
-
|
59 |
media_type="application/json; charset=utf-8",
|
60 |
)
|
|
|
16 |
This api converts a number to Thai text and adds a suffix “บาท” (Baht).
|
17 |
"""
|
18 |
return JSONResponse(
|
19 |
+
{"bahttext": py_bahttext(number)},
|
20 |
media_type="application/json; charset=utf-8",
|
21 |
)
|
22 |
|
|
|
27 |
Normalize and clean Thai text
|
28 |
"""
|
29 |
return JSONResponse(
|
30 |
+
{"text": py_normalize(text)},
|
31 |
media_type="application/json; charset=utf-8",
|
32 |
)
|
33 |
|
|
|
38 |
Thai tone detector for word.
|
39 |
"""
|
40 |
return JSONResponse(
|
41 |
+
{"tone": py_tone_detector(syllable)},
|
42 |
media_type="application/json; charset=utf-8",
|
43 |
)
|
44 |
|
|
|
55 |
- **text**: Spelled-out numerals in Thai scripts
|
56 |
"""
|
57 |
return JSONResponse(
|
58 |
+
{"number": py_thaiword_to_num(text)},
|
59 |
media_type="application/json; charset=utf-8",
|
60 |
)
|