ahhyoushh/zip-surprisal
Surprisal
ahhyoushh/zip-surprisal
Surprisal
A language identifier in ~250 lines of C that classifies text by comparing LZ77 compression costs against reference texts, with no machine learning or training required.
Visit project- First shared
- Oct 13, 2026
- HN activity
- 10
Show HN@iushhOct 13, 2026
Show HN: Surprisal – a language identifier in ~250 lines of C. No ML,no training
I made a text/language identifier today, in a single C file, with no ML. It classifies a text by checking which reference text a hand-rolled greedy LZ77 compressor finds least surprising. Each class is just a file of reference data. For a query, it sums the bits the compressed output would cost against each reference, and the cheapest one wins. It never writes a compressed file. I got this idea after watching 3b1b's compression is intelligence series for the 3rd time, so i had to make sure i understand it finally. I have my intro to C exam tomorrow, so feedback on the C is welcome.
Community