Replacing Repeated Fragments with Dictionary Entries

A dictionary codec can assign compact references to repeated fragments and restore them during decoding.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace a toy dictionary
  2. Account for transmitting the dictionary
  3. Count dictionary cost along with references
  4. Keep literal spelling distinct from a reference marker

Trace a toy dictionary

Suppose one entry maps code 3 to the text “north”. A sequence of two references to 3 can reconstruct that fragment twice with boundaries supplied by the format. See structured lookup.

Account for transmitting the dictionary

If both ends do not already share it, the stream must describe or derive its entries. For tiny input that overhead can dominate. See size including framing.[1][2]

Count dictionary cost along with references

A message repeats phrase “north bridge” several times. A dictionary can store that phrase once and put a shorter reference at each occurrence. The result saves bytes only if substitutions outweigh the dictionary and framing overhead. See total compressed size.

Phrase length 12 bytes in ASCII
Four literal copies: 48 bytes
Four 1-byte references plus 12 dictionary bytes: 16 bytes before framing
Compare complete sizes

Keep literal spelling distinct from a reference marker

The decoder must tell reference tokens from arbitrary literal input. Include escape and dictionary-boundary rules. Test a short message with an unused dictionary and one containing the reserved marker.

References

  1. Claude E. Shannon, A Mathematical Theory of Communication ↩
  2. David J. C. MacKay, Information Theory, Inference, and Learning Algorithms ↩