[MWForum]MIA, Ask an Expert Question
Jeff Knope
mwforum@lists.mathcats.com
Thu, 26 Feb 2004 16:17:19 -0800
Hi Jolene,
It's been a few days since your inquiry re madlibs programming, and unless
you've gotten "off-forum" responses, you're maybe surprised by the deafening
silence. This same subject came up in the forum about three months ago, and
generated a few responses at that time.
Personally, I don't know madlibs from adlibs. But I can pass along an
answer offered by Harvey Bornfield. As you'll see, Harvey likes to swoop
around a subject for a bit, before he nails it. But that's okay. I suggest
you be sure to use the Help system to look up the details of using the
primitives that he discusses.
Okay. Heeeeeeere's Harvey!:
This is a wonderful project, especially as conceived with user input from
the children. I want to creatively visualize some of the challenges in
grounding such a project in actual code. I'll postpone sharing the literal
programming code for a short while, but attempt to touch down on the
sequence of chores and adventures in such a way as puts spin and leaven on
the enterprise, and yet reveals some of the logo commands necessary to put
the project together.
To do Madlibs justice, on the level of allowing children to feed the program
with original contributions, one first envisions an archive of stories,
named in 'hybrid_titled" files, files that could be stored and retrieved
utilizing "loadtext <author_storytitle> . Using the files command, an
inventory of current offerings in a single directory, can first present to
the user choices. You could author a 'splash' page, in which these files
could be turned into the titles of buttons, which when clicked would summon
the file onscreen.
You'll name a textbox to receive, that is, to display whatever textfile is
chosen, perhaps something named "Storyline"; you'll be feeding the
user-selected <author_title> into Storyline. Which may be showing or hidden.
The story has to be typed in such a way that it's possible to distinguish
which words to retrieve, that is, words "earmarked" for user input. A
decision might be made to embed those words formatted in a say to
distinguish them from the inert components of the tale. for example, I have
fooled around with this:
In a <SEASON> of the year a <PROFESSION> set off with <NAME>, his trusty
sidekick <PET>.
The words in blue are, as Tolkein might say, "destined to become, each and
every one, the sprawling title of a noble textbox" to accept user-input. One
wants to automate this with loops, which creates epic challenges to new
programmers. So a description of how this comes about in English is valuable
to confronting and comprehending the mechanics at a later time.
So there follows developing routines to scan the "Storyline" textbox, and
'tweeze out' those <words>. One of the very interesting and sophisticated
features of Microworlds, is that analyzing the "lines" in a textbox requires
knowledge of applying commands and reporters like TEXTITEM and TEXTCOUNT,
commands peculiar to dealing only with the contents of a textbox. Each
textitem, referred to in MW code as as TEXTITEM 1 "storyline, TEXTITEM 2
"storyline, etc, is a collection of one or more sentences which seem glued
together and which end when a carraige return (the Enter Key) is
encountered. Carraige returns separate these typically multi-sentence lines
which keep their identity as part of a single textitem even when a textbox
window is resized. Magically convenient from a graphics standpoint.
But we have to find a way to take our mental scalpel and slicing textitems
apart, be able to look at individual words embedded within a textitem; here
is where you encounter the PARSE command, which, (when you're dealing with
texts - it has other uses also), chops a textitem into a list of component
words. This is an essential tool. So first you must convert textitems into
lists, (for now, consider them collections of words), lists which are
manipulated through the use of commands like COUNT and ITEM 1, ITEM 2,
FIRST, LAST, etc.
So, this is gear-shifting, a bit tedious, but essential, and it is the PARSE
command which bridges us across the gulf of how textfiles are organized and
analyzed, into lists. Now you get to continue the exciting adventure.
But first!
INTERMISSION: Peanuts, Popcorn, Ice-cream, Sprint no more, kneel and Exhale.
Think velour, rotating snowflakes, rainbow zebras, zephyrs, awestruck,
motionless hummingbirds, the original biological hovercrafts, and seagulls,
balsa-less gliders that silently float at two miles an hour while
meditating.
So? Where were we?
You determine how many pieces of information are in that parsed textitem
utilizing the COUNT reporter, and with bravura, you sweep (looping commands
like: REPEAT, DOTIMES, DOLIST), soaring elegantly through every word in each
list that was once a textitem of a file, asking each word, as it were: "Are
you one of those guys like <SEASON>, <PROFESSION> and <PET> ?, delimited by
"< and >" If so, you get to have your own textbox, named exactly like the
word, and of perfect size for entering the user input.
Now, to make life more challenging, If you're asking the madlib player to
enter parts of speech, it is almost entirely impossible that the input
textbox titles will not require duplication. This MW won't let you do at
least on the same page, so then you have to learn to "Weld" numbers like
"01, "02, etc off the end of the part of speech, ending up with input text
boxes which look like VERB_01, VERB_02. This is a matter that would take us
a little far afield for today. Not having a life, this is what people like
me love to do. :-)
Next task: Once you've identified the names for the collection of user-input
textboxes that you're going to let your programming skill spawn for you
using the "NEWTEXT" command inside a loop, you need a game plan to spray the
boxes out on the screen. So you creatively visualize how many textboxes
would be a maximum, and call up your CRT Visual Handyman or Feng Shui
consultant to landscape your monitor in symmetrical, uncluttered ways.
Do you want the original story, with the <CREATIVEWORDS> replaced by
underscores "______". Do you even want it to be visible while the end-user
is busy spicing it up?
Do you need to have all the text windows present on screen, or do you want
to present them in randomized debuts, one at a time?
When the story is done, do you want to print it?
Finally, the Madlibs has all the components for a fill in the blanks or a
matching test. It would be possible to add programming code to grade
performance, and store the grades in a teacher-accessible file. And for a
variation, turtles might replace words, as visual clues. Multiple
Intelligence is an inspiration.
I will leave these ideas with you all. I have already written the code which
reads up the Storyline textbox (but not yet loaded it from an external
file), and which can generate a textbox, appropriately named for every "<
delimited word. But it does not yet work whan <two words> are presented, and
it steals commas off the end of words. When these chores are solved, I'll
share the project (in MW 2.05)
These are my own approaches to Madlib. Anyone who wants to take the vision
in another direction, should describe the course of the game, and what will
present itself on the screen. Then we can have ammo for collaboration, and
may succeed at sharing and expanding, or downsizing an epic idea and so
making doable, this, as a prelude for figuring out how we might be able to
delegate the creation of and sharing of code in the future. But in the last
analysis, the perfection of the brainstorming, and the focusing of it into
the action sequences is everything. Next to that, writing code is truly
almost trivial.
Best regards,
Harvey Bornfield
www.mythologics.org
----- Original Message -----
From: "Ask an Expert - Question" <askanexpert@openworldlearning.org>
To: <mwforum@lists.mathcats.com>
Sent: Saturday, November 22, 2003 6:58 PM
Subject: [MWForum]MIA, Ask an Expert Question
> This is an automatic message sent from the web form at:
> http://mia.openworldlearning.org/howdoi.htm
>
> from: "jolene" <janzalone@interact.ccsd.net>
> date: Sat, 22 Nov 2003 15:38:15 -0700
>
> I want to create a mad libs type program. I want to ask for
> types of words and have the program remember them. Then put
> all words used into a story. I am taking a masters class
> on microworlds and think this would be a fun project, I
> just don't know how to do what I am invisioning. Thanks in
> advance!
>
> _______________________________________________
> MWForum mailing list
> MWForum@lists.mathcats.com
> http://lists.mathcats.com/mailman/listinfo/mwforum
> Attachments archived at:
> http://www.mathcats.com/mwforum/attachments.html
> To unsubscribe or for administrative questions contact
> mailto:mwforum-admin@lists.mathcats.com
>
>