Developing a Block That Makes Plurals

You can load a snap library at any time from the File menu File button under "Libraries...".
  1. For this project, you will need to load the Words, sentences library.
  2. Experiment with the blocks letter n of word, join, last letter of and all but last letter of to see how they behave.
  3. Experiment boldly: Here are some suggestions. You might try other experiments, too.

    letter 2 of butterflies letter 7 of fly letter minus2 of fly
    letter picked randomly from 1 to 10 of butterfly
    all but last letter of butterfly last letter of all but last letter of brush
    join boss es join t all but first letter of when
    Try join-(t)-all-but-first-letter-of with the words "where" and "what" and "wherefore," too.

The goal now is to build plural, a reporter block that takes a noun as input and outputs the plural of the noun, spelled correctly. plural day (with result) plural boss (with result)

Choose the reporter button when you make the plural block.

select reporter as block type

Here's one way to start building that block.

plural-(script), first try

  1. 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.
  2. 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.
  3. 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.
    • "U2L1-Plural"save your work as U2L1-Plural Save your file. You will need this list.
  4. Rebuild this image without the white background. --MF

    Debugging: To write good code that works, you want to try to "break" it, to find situations in which it does not work. This 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

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

  6. Use map to test all the words on your list. map-plural-over-list-of-nouns

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

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

    You may find these useful in your tests.

  8. Now Is a Good Time to Save
 
  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