Skip to content

[WIP] Add TypeError to digitconv.py #1127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pythainlp/util/digitconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
"1": "หนึ่ง",
"2": "สอง",
"3": "สาม",
"4": "สี่",
"4": "สี่",TypeError
"5": "ห้า",

Check failure on line 41 in pythainlp/util/digitconv.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff

pythainlp/util/digitconv.py:41:15: SyntaxError: Expected ':', found ','

Check failure on line 41 in pythainlp/util/digitconv.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff

pythainlp/util/digitconv.py:41:8: SyntaxError: Expected ',', found ':'

Check failure on line 41 in pythainlp/util/digitconv.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff

pythainlp/util/digitconv.py:41:5: SyntaxError: Expected ':', found string
"6": "หก",
"7": "เจ็ด",
"8": "แปด",
Expand Down Expand Up @@ -84,7 +84,7 @@
# output: เป็นจำนวน 123,400.25 บาท
"""
if not text or not isinstance(text, str):
return ""
raise TypeError("The text must be str type.")

return text.translate(_thai_arabic_translate_table)

Expand All @@ -110,7 +110,7 @@
# output: เป็นจำนวน ๑๒๓,๔๐๐.๒๕ บาท
"""
if not text or not isinstance(text, str):
return ""
raise TypeError("The text must be str type.")

# Convert Arabic to Thai numerals
return text.translate(_arabic_thai_translate_table)
Expand All @@ -122,7 +122,7 @@
:return: Text with digits spelled out in Thai
"""
if not text or not isinstance(text, str):
return ""
raise TypeError("The text must be str type.")

# Convert Thai numerals to Arabic ones
text = text.translate(_thai_arabic_translate_table)
Expand Down
Loading