There are a number of standard functions that allow one to access parts of an utterance and traverse through it.
Functions exist in Lisp (and of course C++) for accessing an utterance. The Lisp access functions are
UTT
.
RELATIONNAME
in UTT
. This
is nil if no relation of that name exists. Note for tree relation will
give the items in pre-order.
RELATIONNAME
in UTT
.
The Lisp bracketing reflects the tree structure in the relation.
RELATIONNAME
in
UTT
. Leafs are defined as those items with no daughters within
that relation. For simple list relations utt.relation.leafs
and
utt.relation.items
will return the same thing.
RELATIONNAME
. Returns nil
if this relation contains no items
RELATIONNAME
. Returns
nil
if this relation contains no items
FEATNAME
in ITEM
. FEATNAME
may be a feature name, feature function name, or pathname (see below).
allowing reference to other parts of the utterance this item is in.
ITEM
. This could also be accessed
as (item.feat ITEM 'name)
.
ITEM
to be NEWNAME
. This is equivalent to
(item.set_feat ITEM 'name NEWNAME)
FEATNAME
to FEATVALUE
in ITEM
.
FEATNAME
should be a simple name and not refer to next,
previous or other relations via links.
RELATIONNAME
, or nil
if
ITEM
is not in that relation.
ITEM
's current relation, or nil
if there is no next.
ITEM
's current relation, or nil
if there is no previous.
ITEM
in ITEM
's current relation, or
nil
if there is no parent.
ITEM
in ITEM
's current relation, or
nil
if there are no daughters.
ITEM
in ITEM
's current relation, or
nil
if there is no second daughter.
ITEM
in ITEM
's current relation, or
nil
if there are no daughters.
As from 1.2 the utterance structure may be fully manipulated from Scheme. Relations and items may be created and deleted, as easily as they can in C++;
t
if relation named RELATIONNAME
is present, nil
otherwise.
RELATIONNAME
. If this relation
already exists it is deleted first and items in the relation are
derefenced from it (deleting the items if they are no longer referenced
by any relation). Thus create relation guarantees an empty relation.
RELATIONNAME
in utt. All items in
that relation are derefenced from the relation and if they are no
longer in any relation the items themselves are deleted.
ITEM
to end of relation named RELATIONNAME
in
UTT
. Returns nil
if there is not relation named
RELATIONNAME
in UTT
otherwise returns the item
appended. This new item becomes the last in the top list.
ITEM
item may be an item itself (in this or another relation)
or a LISP description of an item, which consist of a list containing
a name and a set of feature vale pairs. It ITEM
is nil
or inspecified an new empty item is added. If ITEM
is already
in this relation it is dereferenced from its current position (and
an empty item re-inserted).
ITEM2
into ITEM1
's relation in the direction
specified by DIRECTION
. DIRECTION
may take the
value, before
, after
, above
and below
.
If unspecified, after
is assumed. Note it is not recommended
to insert above and below and the functions item.insert_parent
and item.append_daughter
should normally be used for tree building.
Inserting using before
and after
within daughters is
perfectly safe.
DAUGHTER
, an item or a description of an item to
the item PARENT
in the PARENT
's relation.
DAUGHTER
. NEWPARENT
may
be a item or the description of an item.
FROM
to the position of TO
in TO
's
relation. FROM
will often be in the same relation as TO
but that isn't necessary. The contents of TO
are dereferenced.
its daughters are saved then descendants of FROM
are
recreated under the new TO
, then TO
's previous
daughters are derefenced. The order of this is important as FROM
may be part of TO
's descendants. Note that if TO
is part of FROM
's descendants no moving occurs and nil
is returned. For example to remove all punction terminal nodes in
the Syntax relation the call would be something like
(define (syntax_relation_punc p) (if (string-equal "punc" (item.feat (item.daughter2 p) "pos")) (item.move_tree (item.daughter1 p) p) (mapcar syntax_remove_punc (item.daughters p))))
ITEM1
and ITEM2
and their descendants in
ITEM2
's relation. If ITEM1
is within ITEM2
's
descendants or vice versa nil
is returns and no exchange takes
place. If ITEM1
is not in ITEM2
's relation, no
exchange takes place.
Daughters of a node are actually represented as a list whose first
daughter is double linked to the parent. Although being aware of
this structure may be useful it is recommended that all access go through
the tree specific functions *.parent
and *.daughter*
which properly deal with the structure, thus is the internal structure
ever changes in the future only these tree access function need be
updated.
With the above functions quite elaborate utterance manipulations can be performed. For example in post-lexical rules where modifications to the segments are required based on the words and their context. See Post-lexical rules, for an example of using various utterance access functions.