Searching for a word when it's more than one word
Mark Waddingham
mark at livecode.com
Sat Sep 1 06:45:48 EDT 2018
On 2018-09-01 12:35, Richmond Mathewson via use-livecode wrote:
> That's because you lot tend to use a silver teaspoon while I tend to
> use a great big shovel:
>
> https://www.dropbox.com/s/00t8oftb1ydm8ni/Text%20analyzer%20X.livecode.zip?dl=0
Heh, great big shovels are great for coarse work - e.g. for the problem
of finding occurrences of SINGLE WORD towns in the source text - as you
are in your stack.
However, in this case, that wasn't what was asked for - the problem was
to find multi-word town names with the constraints that first and
longest match always wins with no overlap (i.e. as a human would read
them):
i.e. East Hartford West Palm Beach Colchester Newchester West Chester
With a town list of
East Hartford
Hartford West
West Palm Beach
Palm Beach
Chester
West Chester
Should return:
East Hartford
West Palm Beach
West Chester
Warmest Regards,
Mark.
P.S. The problem is actually exactly the same - in the single-word case
your alphabet are the characters in the language. In the multi-word
case, your alphabet is the set of words in all phrases, with a 'stop'
word.
--
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps
More information about the use-livecode
mailing list