One function
bigram_similarity in careless25/text2digits
The author described this change as “Fix Div by Zero error potential”. It counts as a record because the checks below fail on the code as it stood at a0f4ad971 and pass on a10f678f1, with nothing else changed between the two runs.
Projectcareless25/text2digits
Fix saved2026-04-28
Sharing licenceMIT · LICENSE
Change size+4 −1
What the code was meant to do, written into the code itself as a docstring
Returns a number within the range [0, 1] determining how similar item1 is to item2. 0 indicates perfect dissimilarity while 1 indicates equality. The similarity value is calculated by counting the number of bigrams both words share in common.
The change
| 24 | 24 | ||
| 25 | 25 | similar = [word for word in pairs1 if word in pairs2] | |
| 26 | 26 | ||
| 27 | - | return float(len(similar)) / float(max(len(pairs1), len(pairs2))) | |
| 27 | + | denominator = max(len(pairs1), len(pairs2)) | |
| 28 | + | if denominator == 0: | |
| 29 | + | return 1.0 if word1 == word2 else 0.0 | |
| 30 | + | return float(len(similar)) / float(denominator) |
The check that tells the two apart
fail→pass·tests/test_text_processing_helpers.py::TestBigramSimilarity::test_different_single_chars
fail→pass·tests/test_text_processing_helpers.py::TestBigramSimilarity::test_empty_strings
fail→pass·tests/test_text_processing_helpers.py::TestBigramSimilarity::test_identical_single_char
fail→pass·tests/test_text_processing_helpers.py::TestBigramSimilarity::test_one_empty_one_nonempty
Check file tests/test_text_processing_helpers.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 ita0f4ad971de8708878e091886cf1cac0fd16c8a1
Broken version dated2026-04-24
Moduletext2digits.text_processing_helpers
Units changedbigram_similarity
Fingerprint8923f2c379d62812
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-28Fix how 'oh' is handled
- 2026-04-28Raise valueError if value/scale didnt match
- 2026-04-28find_similar_word
- 2026-04-24split_glues
- 2020-04-29Fix handling of time formats, add tests (from PR #27)