I'm using a list of synonyms to direct a process of query expansion. The format looks like this:
fu=foo
ba=bar
etc=etcetera
werd=word
I'm using a straightforward binary search algorithm to run each of the user input words against this list. The problem is, when it comes to using phrases.
quick brown fox=alphabet
out of this world=space
why hello there=hello
Typical input: why hello there, where can I get an out of this world hopper?
And the desired output is: hello, where can I get an space hopper?
I don't want to run each word pair or tripple through the search too, and I want to avoid a linear search of the thesaurus list against the input as this is inefficient (although the list should be quite small so this an option).
Therefore I'm looking for ways to run binary search on phrases, or to construct the thesaurus in such a way as to compensate for phrases.
I'm using PHP for this. Any suggestions most welcome.