Whole file
domanchi/gibberish-detector
The author described this change as “bug fix: detector now uses model's charset”. It counts as a record because the check below fails on the code as it stood at b47af7a43 and passes on 2cfee8b30, with nothing else changed between the two runs.
Projectdomanchi/gibberish-detector
Fix saved2021-03-03
Sharing licenceMIT · LICENSE
Change size+1 −3
What the code was meant to do, written into the code itself as a save note
bug fix: detector now uses model's charset
The change
| 1 | - | import string | |
| 2 | - | ||
| 3 | 1 | from . import serializer | |
| 4 | 2 | from .model import Model | |
| 5 | 3 | from .util import NGramIterator | |
| ⋯ | |||
| 22 | 20 | self.limit = threshold | |
| 23 | 21 | ||
| 24 | 22 | # TODO: allow specification of charset | |
| 25 | - | self.iterator = NGramIterator(2, charset=string.ascii_letters) | |
| 23 | + | self.iterator = NGramIterator(2, charset=model.charset) | |
| 26 | 24 | ||
| 27 | 25 | def is_gibberish(self, payload: str) -> bool: | |
| 28 | 26 | return self.calculate_probability_of_being_gibberish(payload) > self.limit | |
The check that tells the two apart
fail→pass·tests/detector_test.py::test_handles_values_outside_of_character_map_gracefully
Check file tests/detector_test.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 itb47af7a437a861a3e4d199744457d1a4014dc597
Broken version dated2021-03-01
Modulegibberish_detector.detector
Units changedDetector
Fingerprinte37031521ebd615a
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.