Reading in dictionary from txt file: options for speed
Reading in dictionary from txt file: options for speed
- Subject: Reading in dictionary from txt file: options for speed
- From: Miles <email@hidden>
- Date: Tue, 14 Apr 2009 11:12:06 -0700
[This is sort of in continuation of the thread "Build Settings for Release:
App/Library is bloated", which gradually changed topics.]
I'm trying to find the best way to load in a 2MB text file of dictionary
words and be able to do quick searches.
Simply loading the uncompressed txt file takes about 0.5 seconds which I can
handle. But when I used the following to create an array of the words from
the file:
NSArray *lines = [stringFromFileAtPath componentsSeparatedByString:@
"\n"];
... it took about 13 seconds, which is way too long.
I'm not super concerned about the 2MB of disk space the txt file takes up,
although I wouldn't be mad about decreasing it somehow. And once I get the
whole dictionary in an array, the searches are basically fast enough for my
purposes. I've still been reading up on Huffman encoding if I decide to try
to compress this. However, my main issue now is loading time, and it seems
like this won't help me there.
And, I'm looking into creating a Trie (which is where the previous thread
guided me), although I'm not sure this helps my current issue of loading
time either. I'm thinking that creating a Trie will probably take just as
long, or longer, than simply splitting the file using
'componentsSeparatedByString', right? So, is there some way to store the
trie on disk so that the loading is my final data structure is faster? What
other options do I have to speed this up?
Thanks!
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden