XML-based Natural Language Generation
Practical Exercises
Template-based Generation
Building with Ant
-
Introduction to Ant, from
Ant - The Definitive Guide
(Jesse Tilly & Eric Burke)
-
Exercise 1: Set up the Ant framework.
-
Make a new directory
XMLGen
for your practical work on XML-based Generation.
-
Copy the Ant build file
build.xml into
XMLGen
-
Make 4 subdirectories:
XMLGen/lib,
XMLGen/src, XMLGen/data,
XMLGen/xslt
-
Copy these .jar files
into
XMLGen/lib
-
In
XMLGen, run Ant by "ant".
-
Check the difference between "
ant help",
"ant -help", and
"ant -projecthelp"
-
Exercise 2: Build a
simple XSLT transform program from
Java and XSLT (Eric Burke)
-
Copy the program
SimpleJaxp.java into
XMLGen/src
-
Compile the program by "
ant compile"
-
Copy hello.xml
into
XMLGen/data and
copy hello.xsl
into XMLGen/xslt
-
Run the program by "
ant simpletransform"
-
Remove the compiled program by "
ant clean"
-
Recompile and rerun the program
by "
ant simpletransform"
Getting XML Content
Swing XSLT Transformer
-
Exercise 4: Build a Swing XSLT Transformer program from
Java and XSLT (Eric Burke)
-
Copy
SwingTransformer.java,
TransformerWindow.java,
XMLOutputPanel.java and
ErrorListenerModel.java
into
XMLGen/src
-
As this program uses JDOM, you need
jdom.jar
in
XMLGen/lib
-
Compile the programs by "
ant compile"
-
Run the program by "
ant swingtransform".
This will open a new window "Swing XSLT Transformer"
-
Use the Select XML button to choose an XML file to
transform, for example
XMLGen/data/hello.xml
-
Use the Select XSLT button to choose an XSLT stylesheet,
for example
XMLGen/xslt/hello.xsl
-
Click the Transform button, then view XML Output
(or Transformation Problems, if there are errors)
Transforming and Validating XML
-
No Java programs needed for Exercises 5 and 6
(prove it by doing "
ant clean" first),
but before using Xalan and Xerces,
you need optional.jar
in XMLGen/lib
-
Exercise 5: Transform XML with Xalan XSLT processor
-
Ensure hello.xml
is still in
XMLGen/data and
hello.xsl
is still in XMLGen/xslt
-
Run Xalan XSLT processor by
"
ant xalantransform".
-
Check the output in
XMLGen/build/hello.html
-
Exercise 6: Transform with Xalan and Validate with Xerces XML parser
-
Ensure liter.csv.xml
is in
XMLGen/data
-
Ensure your version of
liter.csv-xml.xslt
is in XMLGen/xslt
(from Assignment 2)
-
Run Xalan by "
ant litertransform"
to make XMLGen/build/liter.xml
-
Run Xerces by "
ant litervalidate".
-
Now do
Assignment 3: Text Planning.
XML Transformation Pipeline
-
Exercise 7: Build an XML transformation pipeline
-
Copy
NLGPipeline.java
into
XMLGen/src
-
Ensure liter.xml
is in
XMLGen/data
-
Ensure your version of
liter.content.xslt
is in XMLGen/xslt
(from Assignment 3)
-
Run "
ant nlgpipecontent"
to do content determination only
-
Ensure your version of
liter.discourse.xslt
is in XMLGen/xslt
(from Assignment 3)
-
Run "
ant nlgpipediscourse"
to do content determination and discourse planning.
This should show the text plan created by the two text
planning stages
-
Run "
ant nlgpipelexical"
to do lexicalization after text planning
This should fail, warning that the stylesheet
liter.lexical.xslt is not in XMLGen/xslt
-
Now do
Assignment 4: Microplanning.
-
Exercise 7 (continued)
-
Ensure your version of
liter.lexical.xslt
is in XMLGen/xslt
(from Assignment 4)
-
Run "
ant nlgpipelexical"
to do lexicalization after text planning
-
Ensure
liter.aggreg.xslt
is in XMLGen/xslt
(from Assignment 4)
-
Run "
ant nlgpipeaggreg"
to do lexicalization and (null) aggregation after text planning
-
Ensure your version of
liter.refexp.xslt
is in XMLGen/xslt
(from Assignment 4)
-
Run "
ant nlgpiperefexp"
to do text planning, lexicalization, aggregation and
referring expressions.
-
Now do
Assignment 5: Surface Realization.
Generation Algorithms
-
These exercises require Sicstus Prolog.
-
Exercise 8: Van Noord's Bottom-Up Generator (BUG) algorithm
-
Copy BUG1.pl into your
directory and study it.
-
Start Prolog and load the generator by the shell command
prolog -l BUG1.pl
-
Run the test suite by the Prolog query
?- test. (don't forget the fullstop)
-
Stop Prolog by
?- halt.
-
Exercise 9: Phillips' bag generation algorithm
-
Copy ChartGen.pl into your
directory and study it.
-
Start Prolog and load the parser/generator by
prolog -l ChartGen.pl
-
Run the test parse by the Prolog query
?- test_parse.
-
Run the test generation by the Prolog query
?- test_gen.
-
These examples are intended to show the basic algorithms in
the simplest possible form.
If you know Prolog, try extending the examples to generate
some new sentences.
Natural Language Generation and Speech Synthesis
-
Exercise 10: Build a complete NLG pipeline
-
Copy a new Ant build file
build2.xml
into
XMLGen
-
Ensure NLGPipeline.java
is in
XMLGen/src
-
Ensure liter.xml
is in
XMLGen/data
-
Ensure your version of
liter.content.xslt
is in XMLGen/xslt
(from Assignment 3)
Run "ant -f build2.xml nlgpipecontent"
to do content determination only
-
Ensure your version of
liter.discourse.xslt
is in XMLGen/xslt
(from Assignment 3)
Run "ant -f build2.xml nlgpipediscourse"
to do content determination and discourse planning.
This should show the text plan created by the two text
planning stages
-
Ensure your version of
liter.lexical.xslt
is in XMLGen/xslt
(from Assignment 4)
Run "ant -f build2.xml nlgpipelexical"
to do lexicalization after text planning
-
Ensure
liter.aggreg.xslt
is in XMLGen/xslt
(from Assignment 4)
Run "ant -f build2.xml nlgpipeaggreg"
to do lexicalization and (null) aggregation after text planning
-
Ensure your version of
liter.refexp.xslt
is in XMLGen/xslt
(from Assignment 4)
Run "ant -f build2.xml nlgpiperefexp"
to do text planning, lexicalization, aggregation and
referring expressions.
This should show the text specification created by the text
planning and microplanning stages
-
Ensure your version of
liter.realize.xslt
is in XMLGen/xslt
(from Assignment 5)
Run "ant -f build2.xml nlgpiperealize"
to do text planning, microplanning and surface realization.
This should show the natural language text generated by
the complete NLG pipeline
-
Exercise 11: NLG and speech synthesis
-
Copy
PipeSpeak.java
into
XMLGen/src
-
Copy these .jar files
into
XMLGen/lib
-
Copy this
speech.properties
file into your home directory
-
Ensure liter.xml
is in
XMLGen/data
-
Ensure all the XSLT stylesheets from Exercise 10
are in
XMLGen/xslt
-
Run "
ant -f build2.xml nlgpipespeak"
Graham Wilcock
Last modified: Wed Jul 23 12:43:58 EEST 2003