Coy - Like Carp, Only Prettier

Damian Conway

School of Computer Science and Software Engineering
Monash University
Clayton 3168, Australia

mailto:damian@csse.monash.edu.au
http://www.csse.monash.edu.au/~damian

Extended Abstract

Error messages
strewn across my terminal.
A vein starts to throb.

Their reproof adds the
injury of insult to
the shame of failure.

When a program dies
what you need is a moment
of serenity.

The Coy.pm
module brings tranquillity
to your debugging.

The module alters
the behaviour of die and
warn (and croak and carp).

It also provides
transcend and enlighten -- two
Zen alternatives.

Like Carp.pm,
Coy reports errors from the
caller's point-of-view.

But it prefaces
the bad news of failure with
a soothing haiku.

The haiku are not
"canned", but are generated
freshly every time.

The data-driven
poem generator has
three main components.

The first component
is the association
extraction system

This scans the error
message for significant
words (mainly for nouns).

These words are then used
to select a topic for
the nascent haiku.

The next component
generates the haiku by
filling in templates.

Those templates encode
various grammatical
structures for haiku.

The generator
selects one and fills it in
with relevant words.

The words themselves are
stored in a hierarchical,
crosslinked knowledge-base.

The topic chosen
in stage one controls the search
through the dataspace.

Only those links that
have associations with
the topic are used

(and, of course, any
words crosslinked or related
to the topic words).

The last component
adjusts the selected words'
grammar and metre.

First, the chosen words
are inflected into the
right number and tense.

Lingua::EN::Inflect
is used to supply correct
noun/verb agreement.

Currently, tense is
restricted to the present
or continuous.

That's not a problem
though -- all haiku are written
in those two tenses.

Lastly, the chosen
words are inserted into
the grammar template.

Note that this approach
makes no use of semantics
or A.I. techniques.

The very structure
of the knowledge-base ensures
the haiku makes sense.

However, there's no
Guarantee that the result
Scans 5-7-5.

To ensure perfect
Metre, each selected word's
Syllables are checked.

This occurs during
The knowledge-base traversal
Phase, and directs it.

The knowledge-base tracks
The progressive syllable
Count of the words used.

The selection can
Backtrack to other choices
If necessary.

The search continues
Till 17 syllables
Have been selected.

Once the haiku is
complete, it's prepended to
the error message.

Execution of
the original call to
die or warn resumes.

Haiku and error
message strew across my screen.
A smile starts to form.
 

Detailed Outline

  1. Error messages are unpleasant
  2. Canned fish smells bad after a few days
  3. Components of a haiku generator
  4. The Coy.pm interface and implementation
  5. Future work
  6. Conclusion
  7. References

Full Paper

HTML and
PostScript versions of the full
paper are on-line.

Source Code

The Coy.pm
module is available
via the CPAN.