searching dictionary

BlitzPlus Forums/BlitzPlus Programming/searching dictionary

Chevron(Posted 2006) [#1]
Hi,
I would like to search a dictionary file to see if a word is valid.
I have a text file where all english words are listed alphabetically separated by a space.

I have my own ideas of how I could acheive this but thought it was worthwhile asking you guys as often someone will suggest a much better why of acheiving the same end result.


My idea was to load all the words into 26 banks which handles match the start letter.

And then search through the relevant bank to see if there is a match.

I really need this function to operate very fast as it will hopefully be used in the main game loop.

Please let me know any ideas you may have and code examples if possible.

Thanks in advance.


WolRon(Posted 2006) [#2]
If you are only verifying if a word is valid, then couldn't you furthur break down your database by word lengths?
That way, you won't waste time comparing longer words with shorter ones.

A quick string length check would directly point you to the correct section of the database.


Buggy(Posted 2006) [#3]
WolRon, doesn't the dictionary have long words on both sides of short ones?

Oh, wait. I understand. You're right.


Yan(Posted 2006) [#4]
If you're writing a word puzzle game then perhaps this link may be of use.


CASO(Posted 2006) [#5]
I went to that site that Fred linked to. The downloadable dictionary file is AWESOME but the code I wrote to go with it won't work but that is my problem.