Next: Lexical Organization
Up: Metarules
Previous: Examples
The Access to the Metarules through the XTAG Interface
We first describe the access to the metarules subsystem using buffers with
single metarule applications. Then we proceed by describing the application of
multiple metarules in what we call the parallel, sequential, and cumulative
modes to input tree files.
We have defined a metarule conceptually as an ordered pair of trees. In the
implementation of the metarule subsystem it works the same: a metarule is a
buffer with two trees. The name of the metarule is the name of the buffer. The
first tree that appears in the main window under the metarule buffer is the
left hand side, the next appearing below is the right hand side27.10.
The positional approach allows us to have naming freedom: the tree names are
irrelevant27.11. Since we can save
buffers into text files, we can also talk about metarule files.
The available options for applying a metarule which is in a buffer are:
- For applying a metarule to a single input tree, click on the name of
the tree in the main window, and choose the option apply metarule to tree. You will be prompted for the name of the metarule to apply
to the tree which should be, as we mentioned before, the name of the
buffer that contains the metarule trees. The output trees will be
generated at the end of the buffer that contains the input tree. The
names of the trees depend on a LISP parameter: *metarules-change-name* . If the value of the parameter is false, (the default value), then the new trees will have the
same name as the input, otherwise, the name of the input tree followed
by a dash (`-') and the name of the right hand side of the
tree27.12.
The value of the parameter can be changed by choosing Tools
at the menu bar and then either name mr output trees = input or append rhs name to mr output trees.
- For applying a metarule to all the trees of a buffer, click on the name
of the buffer that contains the trees and proceed as above. The output
will be a new buffer with all the output trees. The name of the new
buffer will be the same as the input buffer prefixed by "MR-". The
names of the trees follow the conventions above.
The other options concern application to files (instead of buffers).
We will first define
the concepts of parallel, sequential and cumulative application of metarules.
One metarule
file can contain more than one metarule. The first two trees, i.e., the first
tree pair, form one metarule - call it mr0. Subsequent pairs in the
sequence of trees define additional metarules --
mr1, mr2, ..., mrn.
- We say that a metarule file is applied in parallel to a tree
(see Figure C.6)
if each of the
metarules is applied independently to the input generating its particular
output trees27.13. We generalize the concept to the
application in parallel of a metarule file to a tree file (with possibly more
than one tree), generating all the trees
as if each metarule in the metarule file was applied to each tree in the
input file.
- {Parallel application of metarules
- We say that a metarule file
mr0, mr1, mr2, ...,mrn is applied in
sequence to an input tree file
(see Figure C.7)
if we apply mr0 to the trees of the input file, and
for each
apply metarule mri to the trees generated as a
result of the application of mri-1.
- {Sequential application of metarules
- Finally, the cumulative application is similar to the sequential,
except that the input trees at each stage are passed to the output together
with the newly generated ones (see Figure C.8).
- {Cumulative application of metarules
Remember that in case of matching failure the output result is decided (as
explained in subsection C.2.3) either to be empty or to be the
input tree. The reflex here of having the parameter set for copying the input
is that for the parallel application the output will have as many copies of
the input as matching failures. For the sequential case the decision is applied
at each level, and setting the parameter for copying, in a certain sense,
guarantees that subsequent metarule applications will not break.
Due to its nature, and unlike the two other modes, the cumulative
application is not affected by this parameter.
The options for application of metarules to files are available by clicking
on the menu item Tools and then choosing the appropriate function
from the following:
- Apply metarule to files:
You will be prompted for the metarule file name which should contain
one metarule27.14, and for input file names. Each input
file name inpfile will be independently submitted to the
application of the metarule generating an output file with the name
MR-inpfile.
- Apply metarules in parallel to files:
You will be prompted for the metarules file name with one or more
metarules and for input file names.
Each input file name inpfile will be independently submitted to
the application of the metarules in parallel. For each parallel
application to a file inpfile an output file with the
name MRP-inpfile will be generated.
- Apply metarules in sequence to files:
The interaction is as described for the application in parallel,
except that
the application of the metarules are in sequence and that
the output files are prefixed by MRS- instead of MRP-.
- Apply metarules cumulatively to files:
The interaction is as described for the applications in parallel
and in sequence, except that the mode of application is cumulative
and that the output files are prefixed by MRC-.
The Tools menu also has entries to change the parameters of execution of
metarules. We saw earlier in this section how to set the parameter that
controls the name of the tree. Another parameter, explained in
Subsection C.2.3, is the one that controls the output result on
matching failure. We can change it in the menu by selecting either copy input on mr matching failure or no output on mr matching failure. Recall
that this parameter does not affect the cumulative mode. The third parameter
controls comments generation. By choosing append metarule comments at
the Tools menu, the subsequent metarule applications will produce output
trees whose comments are the comments at the lhs tree of the metarule
followed by the comments at inp. Both parts are introduced by appropriate
headers, allowing the user to have a complete history of each tree. Choosing
do not append metarule comments makes the comments at the output trees
be exactly the same at the input tree. The third option, clear comments on metarule application, causes the comment field to be left empty at the ouput
trees.
The default values for the tree parameters when XTAG is started are set:
to generate the output trees with the same name as the input; not to copy
the input tree in case of matching failure; and to add the metarule comments
to the output tree.
Next: Lexical Organization
Up: Metarules
Previous: Examples
XTAG Project
http://www.cis.upenn.edu/~xtag