Code
Work on the text itself: regular expressions, two texts compared, words found by pattern or sound, word breaks put back, and words disguised by a language game’s rule.
Word Splitter
Restores word breaks in unspaced text, the usual last step after a cipher is broken. Splits are scored with a unigram model in the manner of Peter Norvig's “Natural Language Corpus Data” (Beautiful Data, 2009): known words cost by how common they are, in six languages, unknown chunks by a character 4-gram model, and dynamic programming keeps the three cheapest readings, drawn as arcs over the letters.
History, how it works, how it was checked, limits
History
Peter Norvig’s “Natural Language Corpus Data”, in Beautiful Data (O’Reilly, 2009), with its code and data, segments unspaced text by a unigram model: a reading’s probability is the product of its words’. Restoring the spaces is the usual last step after a cipher is broken, as cipher output often comes unspaced or in groups of five.
How it works
Existing spaces are removed first, or kept as breaks. In English a known word of rank r costs as if its probability were 0.1/r, by Zipf’s law, with ranks from 6,011 hand-ranked words; the shared word list, a rare tier and regular inflections bring the vocabulary to 108,435 forms. In German, French, Italian, Spanish or Latin a word costs by its share of the words of the language’s public-domain books, from its ranked list. Any other chunk is costed by a character 4-gram model. Dynamic programming keeps the best reading and up to two alternatives at most a hundred times less likely. Case, digits and punctuation stay in place; unknown chunks are underlined, with a warning when fewer than 60% of 20 letters or more fall in known words. The figure draws the letters with each word of the reading as an arc, and under them the words of each alternative where it parts from the reading.
How it was checked
The tests split the pangram, keep case, rejoin five-letter groups, keep given spaces, place punctuation, a clitic and an ordinal (DON’TBELATE,MEETATTHE4THGATE.), see through CAFÉ’s accent, pass Greek through and keep KOWALSKI whole as an extra word. MEET ME AT THE OLD BRIDGE must be offered, as the best reading or an alternative; nine of ten benchmark sentences must come out exactly, and 2,000 letters split within a second. A sentence in each of the five other languages comes out exactly, German typed with its umlauts too. The figure’s arcs are tested to be the reading’s words and its brackets the alternative’s.
The tests hold 44 checks of this tool. None names outside material: they are properties the code is held to. Every tool’s checks
Limits
English keeps its hand-ranked model, not yet the books’ list. The other lists are what old books write, with no inflections added; in French and Italian an article elided without its apostrophe (LATTAQUE) is not known. A unigram model has no context, so equally plausible readings can swap (MEETMEAT reads MEET MEAT, with ME AT as an alternative), and a name beside short common words can be broken (ASKOWALSKI as ASK OWAL SKI) until it is given as an extra word.