Answer: Dictionary Compression: Solving the Mystery of "01

  • Context: Comp Sci 
  • Thread starter Thread starter Villiers
  • Start date Start date
  • Tags Tags
    Compression
Click For Summary
SUMMARY

The discussion clarifies the concept of dictionary compression, specifically how assigning a binary code to frequently used words can significantly reduce data size. For instance, the word "because," which appears 50 times in a 100-page document, can be represented by the code "01," resulting in a reduction of 38 bits per occurrence. The conversation also corrects a misunderstanding regarding the size of the lookup list, emphasizing that it pertains only to the words present in the document rather than an entire dictionary. The calculation of bits required for unique word assignment is also addressed, confirming that 19 bits are needed for Webster's Dictionary, while 18 bits can accommodate 262,144 unique entries.

PREREQUISITES
  • Understanding of binary encoding and bit representation
  • Familiarity with dictionary compression techniques
  • Knowledge of data storage concepts and overhead
  • Basic principles of data compression algorithms
NEXT STEPS
  • Research "Huffman coding" for efficient data compression methods
  • Explore "Lempel-Ziv-Welch (LZW) compression" for practical applications
  • Learn about "Run-Length Encoding (RLE)" as a simple compression technique
  • Investigate "Data structure optimization" for efficient storage solutions
USEFUL FOR

Data scientists, software engineers, and anyone involved in data compression and storage optimization will benefit from this discussion.

Villiers
Messages
7
Reaction score
0
Homework Statement
In a text document each letter could be stored as an ASCII code of 8 bits
In this document the word ‘because’ requires 56 bits of data (7 letters x 8 bits)
Instead, the word could be added to a dictionary and assigned the binary code 01 which is a reduction of 38 bits for each occurrence
A saving for 50 occurrences of the word:
Relevant Equations
50 x 54 bits saving = 2,700 bits saved, or 338 bytes
Hi

I have the answer to the dictionary compression question- but can't understand the following in the notes:

Instead, the word could be added to a dictionary and assigned the binary code 01 which is a reduction of 38 bits for each occurrence - what does this mean?

This is the extract in full:
In compressing larger volumes, a document of 100 pages could contain the word ‘because’ 50 times, resulting in 2000 bits of data being required. Instead the word could be added to a dictionary and assigned the code 01 which is a reduction of 38 bits for each occurrence. There would still be a slight overhead in terms of the storage of the dictionary but this would only be a one-off entry per word.
 
Physics news on Phys.org
Words could be assigned a number, which is stored instead of the entire word. Webster's Dictionary contains 470,000 words. That would require 19 bits to give each word a unique number. The explanation you quoted seems to use 18 bits instead of 19 (because 56-38=18). That would allow you to assign unique numbers to ##2^{18} = 262,144## words.

CORRECTION: It looks like it is talking about making a lookup list of only the words in the document, not an entire English language dictionary. So the word ‘because’ is the first word in the lookup list with index 01 and any occurrence of that word in the text is replaced by '01'.
 
Last edited:
thank you for your feedback
 
FactChecker said:
Words could be assigned a number, which is stored instead of the entire word. Webster's Dictionary contains 470,000 words. That would require 19 bits to give each word a unique number. The explanation you quoted seems to use 18 bits instead of 19 (because 56-38=18). That would allow you to assign unique numbers to ##2^{18} = 262,144## words.
I don't think this is what the question means, you are adding in assumptions which I can't see are justified.

Let's have another look:
Villiers said:
In compressing larger volumes, a document of 100 pages could contain the word ‘because’ 50 times, resulting in 2000 bits of data being required.
So each occurrence of 'because' requires 2000 ÷ 50 = 40 bits. This is clearly not ASCII so the calculation 7 x 8 = 56 bits is not relevant.

Villiers said:
Instead the word could be added to a dictionary and assigned the code 01 which is a reduction of 38 bits for each occurrence.
01 is two bits, 40 - 2 = 38.
 
  • Like
Likes   Reactions: FactChecker
pbuk said:
I don't think this is what the question means, you are adding in assumptions which I can't see are justified.
I stand corrected. It looks like it is talking about making a lookup list of only the words in the document, not an entire English language dictionary. So the word ‘because’ is the first word in the lookup list with index 01 and any occurrence of that word in the text is replaced by '01'.
 
  • Like
Likes   Reactions: pbuk

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 3 ·
Replies
3
Views
3K
Replies
8
Views
5K
  • · Replies 19 ·
Replies
19
Views
9K
  • · Replies 25 ·
Replies
25
Views
5K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 15 ·
Replies
15
Views
6K