PG: This /has/ a learning purpose. It's lost in "optional." The learning purpose is couched in machine generation of language, but the content/programming goals are also practice of old, learning new, and foreshadowing. The important "new" is the essential element of problem decomposition and abstraction: this problem is too difficult /without/ decomposing it, but perfectly tractable /with/ decomposition. And then, perfectly extensible to Spanish or...
Brian and Mary are considering possibly one day making these two pages into a non optional lab before or after Lab 4. --MF, 1/2/21
gossip
, that writes. In this project, you will extend the computer's abilities with language by developing a reporter block, plural
, that takes a noun as input and correctly spells and outputs the plural last letter of
will report if, say, "2017" is its input.)
plural
.plural
block. Build this much and test it out on at least "day" and "boss" and "medicine," to make sure it works correctly for those. If it does not, edit and fix it. plural
does not work correctly. List the words you find. Organize that list, sorting the words into categories according to their last letter. For example, it will get wrong some words that end with the letter "h". Try to find many words it gets wrong. plural
block should now work correctly for "day" and "boss" and "moth," but it probably doesn't yet work correctly for the word "box":plural
block to make it work for words that end with "x". Test it to make sure it does work properly.
You can do the same for conjugating verbs in Spanish or some other language you choose. See the Take It Further section at the bottom.
The next two steps are worth learning—very useful for testing plural
and in more advanced work later on—but not essential for building plural
.
map
to test all the words on your list. Leave the slot in plural
empty, as you see here. The map
block inserts each element of the list into that slot and reports a list of the results.map
script, replace plural
with. Try it. Now explain what the map
block does, in general. last letter of
empty, as you see here. That is the placeholder for keep
to test each word the list. Explain what the keep
block does.