Next: Features, Previous: Utterance modules, Up: Utterances [Contents][Index]
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
returns a list of the names of the relations currently created in UTT
.
returns a list of all items in RELATIONNAME
in UTT
. This
is nil if no relation of that name exists. Note for tree relation will
give the items in pre-order.
A Lisp tree presentation of the items RELATIONNAME
in UTT
.
The Lisp bracketing reflects the tree structure in the relation.
A list of all the leafs of the items in 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.
returns the first item in RELATIONNAME
. Returns nil
if this relation contains no items
returns the last (the most next) item in RELATIONNAME
. Returns
nil
if this relation contains no items
returns the value of feature 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.
Returns an assoc list of feature-value pairs of all local features on this item.
Returns the name of this ITEM
. This could also be accessed
as (item.feat ITEM 'name)
.
Sets name on ITEM
to be NEWNAME
. This is equivalent to
(item.set_feat ITEM 'name NEWNAME)
set the value of FEATNAME
to FEATVALUE
in ITEM
.
FEATNAME
should be a simple name and not refer to next,
previous or other relations via links.
Return the item as viewed from RELATIONNAME
, or nil
if
ITEM
is not in that relation.
Return a list of relation names that this item is in.
Return the relation name that this item is currently being viewed as.
Return the next item in ITEM
’s current relation, or nil
if there is no next.
Return the previous item in ITEM
’s current relation, or nil
if there is no previous.
Return the parent of ITEM
in ITEM
’s current relation, or
nil
if there is no parent.
Return the first daughter of ITEM
in ITEM
’s current relation, or
nil
if there are no daughters.
Return the second daughter of ITEM
in ITEM
’s current relation, or
nil
if there is no second daughter.
Return the last daughter of ITEM
in ITEM
’s current relation, or
nil
if there are no daughters.
Return a list of all lefs items (those with no daughters) dominated by this item.
Find the next item in this relation that has no daughters. Note this may traverse up the tree from this point to search for such an item.
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++;
returns t
if relation named RELATIONNAME
is present, nil
otherwise.
Creates a new relation called 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.
Deletes the relation called 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.
Append 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).
Insert 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.
Append DAUGHTER
, an item or a description of an item to
the item PARENT
in the PARENT
’s relation.
Insert a new parent above DAUGHTER
. NEWPARENT
may
be a item or the description of an item.
Delete this item from all relations it is in. All daughters of this item in each relations are also removed from the relation (which may in turn cause them to be deleted if they cease to be referenced by any other relation.
Remove this item from this relation, and any of its daughters. Other relations this item are in remain untouched.
Move the 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))))
Exchange 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.
Next: Features, Previous: Utterance modules, Up: Utterances [Contents][Index]