User Tools

Site Tools


Finding Key Words: The -match- and -storen- Commands

The -match- command, a judging command, makes it easy to look for key words in a student's response. The -match- command will not only find a word in the midst of a sentence, but it will replace the found word in the judging copy with spaces, to facilitate the further use of additional judging commands (including -match-) to analyze the remainder of the response. Here is the form of a -match- statement:

match num,dog,(cat,feline),horse,(pig,hog,swine)0123

Here “num” is a variable which will be set to -1 if none of the listed words appear in the student's response, to 0 if “dog” appears, to 1 if “cat” or “feline” is present, 2 if “horse” is in the response, etc. In any case, -match- terminates judging, with a “no” judgment if num= -1 or an “ok” judgment otherwise. What if more than one of the words appear in the student's response? Suppose the student says:

"horse and dog"
In this case “num” will be set to 2 because in looking at the first student word we find a match (horse). The judging copy of the response is altered by replacing “horse” with spaces so that it looks like:
" and dog"
f we were to execute the same -match- again we would get the number 0 corresponding to “dog”, and the judging copy would then look like:
" and "
Note that -match- always terminates judging, so that a “judge continue” is needed before another -match- can be executed. Also note that the key words are pulled out in the order in which they appear in the student's response, not in the order they appear in the -match- statement.

There are many other ways in which the -match- can be utilized. First, we can improve greatly on our cursor program:

. . . inhibit arrow arrow 3201 long 1 match num,d,e,w,q,a,z,x,c do num,x,move judge ignore . . .

Unit “move” remains unchanged except to replace (in two places) the expression “anscnt -2” by the expression “num-1” (and we can delete the “judge ignore” in unit “move”). We see that -match is useful for converting a word to a number which represents the word's position in a list.

Another good use of in an index:

unit table base term index at 1218 write Choose a chapter: a) Introduction b) Nouns c) Pronouns d) Verbs arrow 1822 long 1 match chapter,a,b,c,d cafe chapterchapter+ 1 jump chapter,x,x,intro,unoun,pron,verb,x write Pick a,b,c, or d.

Notice that we must increment “chapter” by one if we want topic “a” to be chapter 1, since -match- associates 0 with the first element in its list (-1 is reserved for the case where no match is found). If no match is found, there is a “no” judgment. (Again, -base- could come later in the unit, or at the beginning of the chapters, in which case the BACK key would still be active for returning to the place from which the index was accessed.)

These applications barely scratch the surface of -match-s capabilities. Here are some other ideas on how to use -match-:

  1. Use -match- to pull out 'negation words such as no, not, never, etc. Then “judge continue” and use -answer- or -conceptcommands to analyze the remainder of the response. You can in this way separate the basic concept from whether it is negated, with the negation information held in the -match- variable for easy use in conditional statements.
  2. Use -match- to identify and remove a key-word directive before processing the rest of the information. This comes up in simulating computer compilers, in games (“move” or “capture”), etc.

A related command is -storen-, which will find a simple numeric expression in a sentence, store it in your specified variable, and replace the expression with spaces. This is particularly useful for pulling out several numbers. The -store- command will handle much more complicated expressions including variables as well as numbers, but can get only one number. For example, the student might respond to a question about graph-plotting coordinates with “32.7,38.3”. These two numbers can be acquired by:

. . . arrow 1215 storen x write You haven't given me numbers. storen y write You only gave me one number. answer $$ remainder should be essentially blank no write There should just be two numbers.

Like -store-, -storen- will terminate judging on an error condition (in which no number was found). In the example, the first -storen- removes and stores one number in “x” and the second -storen- looks for a remaining number to store in “y”. The first -storen- will terminate judging if there are no numbers. The second -storen- will terminate judging if there is no number remaining after one has been removed. The blank -answer- will be matched if only punctuation, such as commas, remains after the actions of the two -storen-s.

Numerical and Algebraic Judging: -ansv- and -wrongv-

plato/tutor/finding_key_words.txt · Last modified: 2023/08/05 18:55 by Site Administrator