Spaces:
Running
on
Zero
Running
on
Zero
Update goai_helpers/utils.py
Browse files- goai_helpers/utils.py +9 -2
goai_helpers/utils.py
CHANGED
@@ -86,7 +86,11 @@ class MooreConverter:
|
|
86 |
self.thousands = ["", "tusri"]
|
87 |
# thousands_prefix not used in this implementation; recursion is clearer
|
88 |
|
89 |
-
def number_to_moore(self, n: int) -> str:
|
|
|
|
|
|
|
|
|
90 |
if n == 0:
|
91 |
return "" # keep original behavior, but expand_number will fallback to the digits for zero
|
92 |
|
@@ -151,7 +155,10 @@ class MooreConverter:
|
|
151 |
else:
|
152 |
# Use recursion here: for any thousands_count (can be >= 10),
|
153 |
# express the thousands_count in Mooré then append "tusri"
|
154 |
-
result =
|
|
|
|
|
|
|
155 |
|
156 |
if remainder > 0:
|
157 |
result += " la " + self.number_to_moore(remainder)
|
|
|
86 |
self.thousands = ["", "tusri"]
|
87 |
# thousands_prefix not used in this implementation; recursion is clearer
|
88 |
|
89 |
+
def number_to_moore(self, n: int, is_price: bool = False) -> str:
|
90 |
+
if is_price:
|
91 |
+
n = n / 5
|
92 |
+
n = int(n)
|
93 |
+
|
94 |
if n == 0:
|
95 |
return "" # keep original behavior, but expand_number will fallback to the digits for zero
|
96 |
|
|
|
155 |
else:
|
156 |
# Use recursion here: for any thousands_count (can be >= 10),
|
157 |
# express the thousands_count in Mooré then append "tusri"
|
158 |
+
result = self.thousands[1] + " " + self.number_to_moore(thousands_count)
|
159 |
+
result = result.replace("tusri", "tusa")
|
160 |
+
if n >= 10000:
|
161 |
+
result = result.replace("tusa", "tus")
|
162 |
|
163 |
if remainder > 0:
|
164 |
result += " la " + self.number_to_moore(remainder)
|