next up previous contents
Next: Summary of match Up: CHAPTER.7: THE POP-11 Previous: Retrieving details of

Using a "restriction" to control or check the match

The basic concept of matching as illustrated so far uses identity between elements of the target list and corresponding elements of the pattern specification. We can generalise this by requiring that a target element have some specified PROPERTY.

For example in the ELIZA world, the occurrence of a word indicating reference to the family e.g. "son", "sister", "father", "mother", etc. in an input sentence is an important response-determining cue. To detect that a list element belongs to such a set, rather than being identical with a given pattern element, we can use a "restriction procedure" as an affix to a queried variable in the pattern specification. Thus if we have a procedure that produces TRUE when applied to family word and false otherwise, then we can use it to restrict the value of "x" in the following match:

    vars x;
    [my father loved me] matches [== ?x:family ==] =>
    ** <true>
    x =>
    ** father

    [you remind me of my brother] matches [== ?x:family ==] =>
    ** <true>
    x =>
    ** brother


    [you remind me of my car] matches [== ?x:family ==] =>
    ** <false>
where FAMILY is a (previously-defined) procedure that might be something like this:

    define family(word) -> result;
      member(word, [son sister father mother brother]) -> result
    enddefine;
You can gain experience with MATCHES ?, ??, ^, ^^, and variables by working through TEACH RESPOND.

See also TEACH MATCHES, TEACH ARROW



Aaron Sloman
Fri Jan 2 03:17:44 GMT 1998