Of course there are a couple of different ways to do this, depending on how
picky you are with matching sub-strings. Something (simple) you might be
searching for is:

        cat-rules: [[thru "kitty" | thru "cat" | thru "feline"] to end]

        print parse "I have a cat and a dog" cat-rules
        print parse "I have a horse and a dog" cat-rules

However, this will also match:

        print parse "I am catatonic" cat-rules

To get a really good match (and not match sub-patterns of words) I think
you'd have to use a loop:

        cat-words: ["kitty" "cat" "feline"]

        sentence: "I have a cat and a dog"
        x: foreach this-word parse sentence none [
                either find cat-words this-word [break/return
this-word][none]
        ]
        print x

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 23, 2000 5:58 PM
To: [EMAIL PROTECTED]
Subject: [REBOL] Newbie question #2 - Pattern making and using?


Ok... how do i make a pattern so that one word eg cat:
can mean cat feline tiger etc.  The following works,
but this code looks imperfect.

x: none
cat: "feline" 
cat: "kitty"
fact: "I have a kitty"
if found? find fact cat [x: "found it"]
if found? x [print x]
unset 'x

How can i make the 2 values of cat: into a pattern
that can be used in this script?  Also, the rest of
this script stinks... THERE MUST BE A BETTER WAY!!!

Humbly, 
T Brownell


__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com

Reply via email to