Have you tried splitting the full dictionary into sub-dictionaries (as an offline, pre-processing step) and then having your application load them in sequence, one at a time? It might be that creating separate arrays and then joining them is faster than creating one array for the entire dictionary at once.

Another alternative might be to store your dictionary as a plist rather than a txt file, and use NSArray's arrayWithContentsOfFile. It might load faster that way. And, if I'm not mistaken, you can save the plist in binary form, rather than XML or plain text, which surely would load faster.

You're right, though, that using a trie won't help you to decrease the loading time, since creating the trie will happen after you've loaded the dictionary. Have you looked at the OMNI trie?

Wagner

On Apr 14, 2009, at 8:12 PM, Miles wrote:

[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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/jrcapab%40gmail.com

This email sent to jrca...@gmail.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to