|
|
|
from fastapi import APIRouter |
|
from pythainlp.util import ( |
|
bahttext as py_bahttext, |
|
normalize as py_normalize, |
|
tone_detector as py_tone_detector |
|
) |
|
router = APIRouter() |
|
|
|
@router.post('/bahttext') |
|
def bahttext(number: float): |
|
""" |
|
This api converts a number to Thai text and adds a suffix “บาท” (Baht). |
|
""" |
|
return {"bahttext": py_bahttext(number)} |
|
|
|
@router.post('/normalize') |
|
def normalize(text: str): |
|
""" |
|
Normalize and clean Thai text |
|
""" |
|
return {"text": py_normalize(text)} |
|
|
|
@router.post('/tone_detector') |
|
def tone_detector(syllable: str): |
|
""" |
|
Thai tone detector for word. |
|
""" |
|
return {"tone": py_tone_detector(syllable)} |
|
|