generateMap(str, minLength = 4, minFreq = 2, flag)
Generates a compression dictionary automatically based on word frequency in the input string.
Parameters:
str– Input string.minLength– Minimum length of words to consider. Defaults to4.minFreq– Minimum frequency of words to include. Defaults to2.flag– Optional flag prefix for keys. Defaults to the instance flag.
Returns: Dictionary object mapping words to short keys.
Example:
1const map = compressor.generateMap("hello world hello world", 3, 2);2// { hello: '$a', world: '$b' }