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
plural (day) reporting (days) plural (boss) reporting (bosses)
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 Snap! File menu button under “Libraries…”.

  1. To do this project, you will need to use the new blocks last letter of (), and all but last letter of (). You will also need (list () () () ()) contains () and join () (), which you used in Unit 1 Lab 2, Gossip and Greet.
    Click here to load this file. Then save it to your Snap! account.
    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: last letter of (butterfly) reporting 'y' reports “y”, but you want to say what last letter of will report if, say, “2017” is its input.)
  2. You won’t need join (t) (all but first letter of (when)) 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.
    Image of 'Make a block' dialog box with the 'Operators' palette selected and the 'Reporter' block shape selected. The palette has 10 menus (Motion, Looks, Sound, Pen, Lists, Control, Sensing, Operators, Variables, Other); a text box; three block shape options (puzzle-shaped/'Command', oval/'Reporter', and hexagonal/'Predicate') labeled 'Select a shape.'; two radio boxes ('for all sprites', which is checked, and 'for this sprite only', which is not checked); and two buttons (OK and Cancel).

  3. 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.
    plural (word) {
if (s = last letter of (word)) {
report (join (word) ('two letters: es'))
}
report (join (word) ('one letters: s'))
}
  4. 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.
  5. Save your list.

    1. Create a Snap! list like this a list block containing: day, boss, moth, box, butterfly, brush... (the end of the image is cut off) containing all of your test words (successful or otherwise).
    2. “U2-Plural”save your work as U2-Plural Save your file. You will need this list.

  6. 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”:
    suffix s box (with wrong result)
    Edit your plural block to make it work for words that end with “x”. Test it to make sure it does work properly. Save your work

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.

  1. Use 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 (plural ( )) over 'a list block containing: day, boss, moth, box, butterfly, brush...' (the end of the image is cut off)
    For now, don’t worry about the words it still gets wrong, as long as it works for “day,” “boss,” “moth,” and “box.”
  2. In your map script, replace plural withjoin () (y). Try it. Now explain what the map block does, in general.
  3. Experiment with
    keep items (last letter of 'empty input slot' = h) from 'a list block containing: day, boss, moth, box, butterfly, brush...' (the end of the image is cut off)
    and
    keep items (last letter of 'empty input slot' = y) from 'a list block containing: day, boss, moth, box, butterfly, brush...' (the end of the image is cut off)
    to see what they do. Again, leave the slot in 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.
  1. 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:
    conjugate verb (Spanish), pronoun: (nosotros) verb: (comer) reporting 'comemos' conjugate verb (Spanish), pronoun: (yo) verb: (tocar) reporting 'toco'