2 ms·
The compression of a trie may not be the best because of the node storage requirement. I've benchmarked the memory usage of some Python trie libraries here: htt
by kmike84 14y ago
The compression of a trie may not be the best because of the node storage requirement. I've benchmarked the memory usage of some Python trie libraries here: http://kmike.ru/python-data-structures/ http://kmike.ru/python-data-structures/
I also tried to compress "/usr/share/dict/words" with https://github.com/kmike/DAWG https://github.com/kmike/DAWG and https://github.com/kmike/marisa-trie https://github.com/kmike/marisa-trie Python libraries:
import dawg
import marisa_trie
words = open('/usr/share/dict/words', 'r').read().splitlines()
dawg.DAWG(words).save('words.dawg')
marisa_trie.Trie(words).save('words.trie')
The result is a bit surprising:
1220612 words.dawg
743128 words.trie
Please note that MARISA-trie is not a classic trie, it is a smart & crazy recursive trie (something like DAWG-Trie hybrid). By the way, I was expecting DAWG to perform much better; for my data (5mln Russian words) the DAWG compression was much more impressive.