Whole file
careless25/text2digits
The author described this change as “Fix how 'oh' is handled”. It counts as a record because the checks below fail on the code as it stood at 8eb8a5ef2 and pass on 5cabbe722, with nothing else changed between the two runs.
Projectcareless25/text2digits
Fix saved2026-04-28
Sharing licenceMIT · LICENSE
Change size+5 −2
What the code was meant to do, written into the code itself as a save note
Fix how 'oh' is handled
The change
| 25 | 25 | SCALE_VALUES = [100, 1_000, 10_000, 1_000_000, 10_000_000, 1_000_000_000, 100_000_000_000, 1_000_000_000_000] # used for has_large_scale | |
| 26 | 26 | INDIAN_SCALES = ['lakh', 'crore', 'arab', 'kharab'] | |
| 27 | 27 | CONJUNCTION = ['and'] | |
| 28 | - | ORDINAL_WORDS = {'oh': 'zero', 'first': 'one', 'second': 'two', 'third': 'three', 'fifth': 'five', | |
| 28 | + | ORDINAL_WORDS = {'first': 'one', 'second': 'two', 'third': 'three', 'fifth': 'five', | |
| 29 | 29 | 'eighth': 'eight', 'ninth': 'nine', 'twelfth': 'twelve'} | |
| 30 | 30 | ORDINAL_ENDINGS = [('ieth', 'y'), ('th', '')] | |
| 31 | 31 | ||
| ⋯ | |||
| 42 | 42 | numwords[word] = (10 ** (idx * 3 or 2), 0) | |
| 43 | 43 | for idx, word in enumerate(INDIAN_SCALES): | |
| 44 | 44 | numwords[word] = (10 ** (5 + idx * 2), 0) | |
| 45 | + | numwords['oh'] = (1, 0) # alias for zero; kept separate to avoid index-10 collision in UNITS enumeration | |
| 45 | 46 | ||
| 46 | 47 | def __init__(self, word: str, glue: str): | |
| 47 | 48 | """ | |
| ⋯ | |||
| 70 | 71 | self._word = replaced | |
| 71 | 72 | ||
| 72 | 73 | # Assign a type to each token (from specific to general) | |
| 73 | - | if self._word in Token.UNITS: | |
| 74 | + | if self._word == 'oh': | |
| 75 | + | self.type = WordType.UNITS | |
| 76 | + | elif self._word in Token.UNITS: | |
| 74 | 77 | self.type = WordType.UNITS | |
| 75 | 78 | elif self._word in Token.TEENS: | |
| 76 | 79 | self.type = WordType.TEENS | |
The check that tells the two apart
fail→pass·tests/test_tokens.py::TestOhToken::test_oh_is_not_ordinal
fail→pass·tests/test_tokens.py::TestOhToken::test_phone_number_concatenation
Check file tests/test_tokens.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it8eb8a5ef29a17c3442aa121fe58e8dc786f74066
Broken version dated2026-04-28
Moduletext2digits.tokens_basic
Units changedToken
Fingerprint7a2a8dc20ff7b3ef
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in careless25/text2digits
- 2026-04-28Raise valueError if value/scale didnt match
- 2026-04-28find_similar_word
- 2026-04-28bigram_similarity
- 2026-04-24split_glues
- 2020-04-29Fix handling of time formats, add tests (from PR #27)