Modeling Language: Plurals, Part 1
Unit 2 Optional Project
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
Siri and other robots are programmed to generate language. Siri speaks; some robots write. You have developed a program, 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
Spelling a plural can seem almost automatic for a person, but it is not simple: a computer needs an algorithm to do that task.
This project uses blocks already loaded for you from Snap!’s “Words, sentences” library. You can load a library from the Snap! File menu under “Libraries…”.
-
To do this project, you will need to use the new blocks , and . You will also need and , which you used in Unit 1 Lab 2, Gossip and Greet.
Try all its expressions (the nine one-line scripts) and experiment with their inputs until you are sure you understand what they do. For each expression, say what that script does in general not just what it does with this particular input. (Example: reports “y”, but you want to say whatlast letter of
will report if, say, “2017” is its input.) -
Here’s one way to start building the
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.
-
Debugging: Try to find words for which this version of
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. -
Save your list.
- Create a Snap! list like this containing all of your test words (successful or otherwise).
-
“U2-Plural” Save your file. You will need this list.
-
Your
plural
block should now work correctly for “day” and “boss” and “moth,” but it probably doesn’t yet work correctly for the word “box”:
Edit yourplural
block to make it work for words that end with “x”. Test it to make sure it does work properly.
You won’t need for the project, but you might find it interesting to try it not only with “when,” as an input but with “where,” “what,” “wherefore.” Linguists use evidence like this to understand the history of a language.
Choose the reporter button when you make plural
.
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
.
-
Use
map
to test all the words on your list. Leave the slot inplural
empty, as you see here. Themap
block inserts each element of the list into that slot and reports a list of the results.
For now, don’t worry about the words it still gets wrong, as long as it works for “day,” “boss,” “moth,” and “box.” -
In your
map
script, replaceplural
with. Try it. Now explain what themap
block does, in general. -
Experiment with
and
to see what they do. Again, leave the slot inlast letter of
empty, as you see here. That is the placeholder forkeep
to test each word the list. Explain what thekeep
block does.
-
If you know another language, build a block that takes a pronoun and verb as input and outputs the correct form of that verb. For example: