From: "Ara.T.Howard" Date: 2005-05-28T04:18:44+09:00 Subject: Re: How to build an index of phrases in a phrase/sentence? On Sat, 28 May 2005, James Edward Gray II wrote: > On May 27, 2005, at 1:39 PM, Dan Fitzpatrick wrote: > >> I am trying to build an indexing structure on some phrases. Most phrases >> will have 2 - 5 parts (words). The resulting array will be dumped into an >> index to find the matching phrases. I don't want to do wildcard searching >> on the resulting array to find the phrase. >> >> I would like to turn "This is some text" into >> >> ["This", >> "This is", >> "This is some", >> "This is some text", >> "is", >> "is some", >> "is some text", >> "some", >> "some text", >> "text"] >> >> The order of the resulting array doesn't matter. When someone searches for >> "is some" or "some text", I want it to find this phrase. I don't want a >> search for "is text" to find this phrase though. > > Perhaps I'm not understanding, but how does the following fail to meet your > needs? > > "This is some text".match(/is some/i) exponential run time vs. O(1) runtime once the index is built maybe? -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | My religion is very simple. My religion is kindness. | --Tenzin Gyatso ===============================================================================