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.

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-
31 from . import serializer
42 from .model import Model
53 from .util import NGramIterator
2220 self.limit = threshold
2321
2422 # TODO: allow specification of charset
25- self.iterator = NGramIterator(2, charset=string.ascii_letters)
23+ self.iterator = NGramIterator(2, charset=model.charset)
2624
2725 def is_gibberish(self, payload: str) -> bool:
2826 return self.calculate_probability_of_being_gibberish(payload) > self.limit

The check that tells the two apart

failpass·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.