Treex::Core::Node::Ordered
version 0.08663
Moose role for nodes which can/should be ordered by the attribute ord (usually following the word order).
ord
The ordering attribute, ordinal number of a node. The ordering should be without gaps, so
print join ' ', map {$_->ord} $root->get_descendants({ordered=>1}); # should print # 1 2 3 ... number_of_descendants
Does this node precede $another_node?
$another_node
Return the closest following node (according to the ordering attribute) or undef if $node is the last one in the tree.
undef
$node
Return the closest preceding node (according to the ordering attribute) or undef if $node is the first one in the tree.
Next four methods for changing the order of nodes (the word order defined by the attribute ord) have an optional argument $arg_ref for specifying switches. So far there is only one switch - without_children which is by default set to 0. It means that the default behavior is to shift the node with all its descendants. Only if you want to leave the position of the descendants unchanged and shift just the node, use e.g.
$arg_ref
without_children
$node->shift_after_node($reference_node, {without_children=>1});
Shifting involves only changing the ordering attribute (ord) of nodes. There is no rehanging (changing parents). The node which is going to be shifted must be already added to the tree and the reference node must be in the same tree.
For languages with left-to-right script: after means "to the right of" and before means "to the left of".
after
before
Shifts (changes the ord of) the node just behind the reference node.
Shifts (changes the ord of) the node behind the subtree of the reference node.
Shifts (changes the ord of) the node just in front of the reference node.
Shifts (changes the ord of) the node in front of the subtree of the reference node.
Return 1 if the node is attached to its parent nonprojectively, i.e. there is at least one node between this node and its parent that is not descendant of the parent. Return 0 otherwise.
Martin Popel <popel@ufal.mff.cuni.cz>
Copyright © 2011 by Institute of Formal and Applied Linguistics, Charles University in Prague
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Treex::Core, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Treex::Core
CPAN shell
perl -MCPAN -e shell install Treex::Core
For more information on module installation, please visit the detailed CPAN module installation guide.