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.

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

2525 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
2626 INDIAN_SCALES = ['lakh', 'crore', 'arab', 'kharab']
2727 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',
2929 'eighth': 'eight', 'ninth': 'nine', 'twelfth': 'twelve'}
3030 ORDINAL_ENDINGS = [('ieth', 'y'), ('th', '')]
3131
4242 numwords[word] = (10 ** (idx * 3 or 2), 0)
4343 for idx, word in enumerate(INDIAN_SCALES):
4444 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
4546
4647 def __init__(self, word: str, glue: str):
4748 """
7071 self._word = replaced
7172
7273 # 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:
7477 self.type = WordType.UNITS
7578 elif self._word in Token.TEENS:
7679 self.type = WordType.TEENS

The check that tells the two apart

failpass·tests/test_tokens.py::TestOhToken::test_oh_is_not_ordinal
failpass·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