Modeling Language: Plurals, Part 1

Need to replace problem decomposition with modularity per AAP-3.B.2 and AAP-3.B.2. See vocab box on 3.2.4, Selecting Specific Data. (Appears on pages U2 furture OP Diagonal Design (mandala); 3.1.4, brick wall; 2.OP.4, plurals 1; and TG for 2.2 and 2.OP) --MF, 4/9/19

Actually, this content is now in 3.1.4. --MF, 1/10/20

We discussed moving the TIF up to the top before the FYTD--something like: You can do this whole project in any language you want (your native language or one you are learning.) --MF, 5/22/18

There are some images that need attention on this page. --MF, 6/6/18

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...

MF: Need to revise to follow Modeling Langauge in U1

Siri and other robots are programmed to generate language. Siri speaks; some robots write. You have developed a program, gossip, that writes. Now, you can 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 (with result) plural boss (with result)
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 File 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-of-items)-contains-(some-item)-predicate 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-with-result-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 this 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.
    select reporter as block type
  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-(script), first try
  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.
    • Create a Snap! list like this snap list block containing day, boss, bulldog(with space at end), box, butterfly, brush, and more of your choosing containing all of your words.
    • "U2-Plural"save your work as U2-Plural Save your file. You will need this list.
  6. Debugging: To write code that works, you want to try to find situations in which it does not work. "Breaking it" requires thinking of wild and exceptional cases, even including inputs that are incorrect in some way, like this example, which has a space at the end. plural of a word with a space following the word

  7. plural should now work correctly for "day" and "boss" and "medicine," 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.

  8. 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-list-of-nouns

    For now, don't worry about the words it still gets wrong, as long as it works for "day," "boss," "medicine," and "box."

  2. In your map script, replace plural withjoin-(empty)-y. Try it. Now explain what the map block does, in general.
  3. Experiment with
    keep-items-such-that-(last-letter-of-(input)-equals-h)-from-test-list
    and
    keep-items-such-that-(last-letter-of-(input)-equals-y)-from-test-list
    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) for nosotros comer conjugate verb (Spanish) for yo tocar