All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.Panel
|
+----java.applet.Applet
|
+----NetLibs.NetLibs
The user can choose from several story templates and then generate a story automatically by retrieving the words from predefined dictionaries, or by typing the words in a form. The templates contain prompts which correspond to certain word categories such as noun, verb, adjective, etc. Each category has its own dictionary file containing words. When the story is generated automatically, the prompts are used to find the categories and then choose a word at random. When the user is typing the words in a form, the prompts appear next to a text field to show the user what type of word is needed. After all words are chosen, the story template is scanned and the prompts are replaced by the chosen words. The resulting story is then displayed in the window.
The story template files refer to the prompts by putting the index in angle brackets like this:
One day, <1> went to the <2>.
This enables the same word to appear in different places in the story.
The template files all end with the ".txt" suffix and have a corresponding prompt file with the same name and the ".prompts" suffix. In the prompts file, each prompt is on a line separated by a 'new line' character. The number in the angle brackets in the template correspond to the line number in the prompt file (starting at 1).
The prompts in the prompt file consist of the name of a dictionary file without the ".words" suffix. There are also currently two special ways prompts can be used. To generate a random number, a prompt like this can be used:
number from 1 to 100
Also, any prompt can begin with a captial letter. In that case, the chosen
word will automatically be capitalized.
The word files all end with the ".words" suffix. Each word is on a line separated by a 'new line' character. When a random word is selected, the appropriate word file is read in and the words are separated into a vector. Then a random number is generated to select the nth word. The word vectors are cached, so if a story template requests 5 nouns, the word file will not be read and scanned 5 times. Also, if you generate another story with the same template, it will be much faster the second time.
Note: In the Macintosh version ("Mac Libs"), the user can create and edit templates and dictionaries. Templates and the resulting stories can contain formatted text and graphics. Also, the prompts can reference properties and rules. The rules can be implemented in the dictionary in a HyperCard-like language. For example, the "verb" dictionary has rules for "past_participle", "present_participle", etc. This eliminates the need to have separate dictionaries for each type.
public NetLibs()
public void init()
public NetLibsCommand getNetLibsCommand()
public boolean action(Event evt,
Object arg)
public void autoGenerateStory()
public void promptGenerateStory()
public void substituteWords(String storyName,
Vector strings)
public boolean commandSelected(int command)
All Packages Class Hierarchy This Package Previous Next Index