Groan

Last updated: 08.05.2002


Files

Parameters

Test Applet


Notes

Grammar format

The grammars parsed by the present Groan system are context-free grammars. They consist of a set of rules that expand non-terminal nodes (categories) into sequences of non-terminal and terminal nodes (words). The first symbol in the grammar is always called 'top'. For example:

Grammar Generates

top --> s;
s --> np vp np;
np --> det n;
vp --> v;
v --> "kicks";
v --> "strokes";
det --> "the";
n --> "cat";
n --> "dog";
n --> "boy";
n --> "girl";

The boy kicks the dog.
The girl strokes the cat.
The cat kicks the dog.
The boy strokes the girl.
etc.

Each rule in the grammar must be terminated by a semi-colon, and the head of the rule is separated from the body by '-->'. The body of the rule may contain preterminals (symbols consisting of the letters 'a..z', 'A..Z' and '_') or terminals (quoted strings, delimited by double quotes).

Groan performs no recursion checking so be careful not to create infinite loops in your grammars.

Files

Filename Description Java Class
GroanPanelApplet Implements an applet that generates and displays random texts. [Java File] [Class File]
RTNGrammar Implements a class of objects to represent simple RTN grammars. [Java File] [Class File]
RTNParser Implements a parser to read RTN grammars from a text file. [Java File] [Class File]
RTNGrammarNode Basic element of the RTNGrammar, this represents the base class for grammar nodes. [Java File] [Class File]
RTNGrammarPreTerminal A subclass of RTNGrammarNode, this class implements nodes which can be further expanded (i.e. syntactic categories). [Java File] [Class File]
RTNGrammarTerminal A subclass of RTNGrammarNode, this class implements terminal nodes (i.e. lexical items). [Java File] [Class File]
ImageButton Implements a simple button that displays an image and responds to mouse-clicks. [Java File] [Class File]
TextDisplayPane Implements a pane that can display a block of text [Java File] [Class File]
ExtendedApplet Implements parameter parsing and other frequently-required applet functionality. [Java File] [Class File]
Project Archive (StuffIt) Sources and CodeWarrior project in StuffIt 5 format for Macintosh users. [StuffIt Archive]  
Project Archive (ZIP) Sources in ZIP format for PC users. [ZIP Archive]  

To download source or class files, click on the file icon with your right mouse button (Windows/UNIX) or click and hold (Macintosh) and choose "Save ..." or "Download ...". Archives containing the sources for this applet are provided in StuffIt 5 and Zip format.

Parameters

Parameter Type Values Default Notes
grammar String - - Partial URL to a grammar file to be used for text-generation.
button-image String - - Partial URL to an image file to be used to display a 'More' button. If no image is specified
button-label String - Generate Label to be used for the button which allows the user to generate more texts. This will be used only if no image button is provided.
show-generate-button Boolean yes, no yes If true
font String - TimesRoman plain 12 Specification of the font to be used for display in format 'family face size'.
background-color Color #rrggbb #FFFFFF Color to be used for the background of the displayed text.
text-color Color #rrggbb #000000 Color to be used for the text displayed.
shadow-color Color #rrggbb #CCCCCC Color used for text shadow if shown.
shadow-offset int - 0 Distance by which text shadow is offset from text. If the offset is 0

Test Applet

[raingod:resources:java] -- [up][links][home]