String matching algorithm
-
Hi. I have a text file full of words (lets say one word per line). I want to find all words starting with a given pattern. What's the best algorithm to do this? Thanks, vSoares
vSoares wrote:
What's the best algorithm to do this?
well, what is your definition of best? best matches? best execution time? best ...? there are plenlenty of algorithms out them, did you try exact string match[^] or this[^]
Yusuf May I help you?
-
vSoares wrote:
What's the best algorithm to do this?
well, what is your definition of best? best matches? best execution time? best ...? there are plenlenty of algorithms out them, did you try exact string match[^] or this[^]
Yusuf May I help you?
Yes, I tried but i was expecting someone who had some experience with this kind of algorithms to point me in the right direction. I agree, "best" is very broad. I need a fast search algorithm. I can optimize the source if needed. It's not an exact string match. It's all strings beggining with a given pattern, something like google suggestions. vSoares
-
Yes, I tried but i was expecting someone who had some experience with this kind of algorithms to point me in the right direction. I agree, "best" is very broad. I need a fast search algorithm. I can optimize the source if needed. It's not an exact string match. It's all strings beggining with a given pattern, something like google suggestions. vSoares
-
Yes, I tried but i was expecting someone who had some experience with this kind of algorithms to point me in the right direction. I agree, "best" is very broad. I need a fast search algorithm. I can optimize the source if needed. It's not an exact string match. It's all strings beggining with a given pattern, something like google suggestions. vSoares
vSoares wrote:
I need a fast search algorithm. I can optimize the source if needed.
Sort the file then use a binary search? :)
Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis
-
Hi. I have a text file full of words (lets say one word per line). I want to find all words starting with a given pattern. What's the best algorithm to do this? Thanks, vSoares
Load them into a database and use SQL. :-D
-
Hi. I have a text file full of words (lets say one word per line). I want to find all words starting with a given pattern. What's the best algorithm to do this? Thanks, vSoares
I think I would give it a try with regex. If you really want to program something nice, then maybe suffix trees are good. Cheers
You have the thought that modern physics just relay on assumptions, that somehow depends on a smile of a cat, which isn’t there.( Albert Einstein)