??ANSWER TO EXERCISE 59

Create a new property adjective, and move names which are adjectives to it: for instance,

    name "tomato" "vegetable", adjective 'fried' 'green' 'cooked',
(Recall that dictionary words can only be written in " quotes for the name property.) Then (using the same IsAWordIn routine),
[ ParseNoun obj n m;
  while (IsAWordIn(NextWord(),obj,adjective) == 1) n++; wn--;
  while (IsAWordIn(NextWord(),obj,noun) == 1) m++;
  if (m==0) return 0; return n+m;
];

Back to the exercise in section 24
Mechanically translated to HTML from third edition as revised 16 May 1997. Copyright © Graham Nelson 1993, 1994, 1995, 1996, 1997: all rights reserved.