3 ms·
Well, nothing prevents this to be a 3-5 lines of Python with more suitable data structures: $ pip install dawg and then import dawg words = open(
by kmike84 14y ago
Well, nothing prevents this to be a 3-5 lines of Python with more suitable data structures:
$ pip install dawg
and then
import dawg
words = open('/usr/share/dict/words', 'r').read().splitlines()
d = dawg.DAWG(words)
(this example actually works)
- lurker14 14y agoLet's not store the whole file in memory at once!
- Lexarius 14y agoOk. import dawg with open('/usr/share/dict/words','r') as words: d = dawg.DAWG(w.strip() for w in words)
- kmike84 14y agoI think the point of using data structures like DAWG is to reduce the memory consumption to the point it is feasable to store the whole dataset in memory. Practical DAWG application would be the following anyway: import dawg d = dawg.DAWG().load('words.dawg') because DAWG minimization may require a lot of memory.