NAME
Treex::Core::Node::Aligned
VERSION
version 2.20210102
DESCRIPTION
Moose role with methods to access alignment.
METHODS
- ($ali_nodes, $ali_types) = $node->get_aligned_nodes($filter)
-
This is the main getter method. It returns all nodes aligned to a specified node
$node, and types of these alignment links as two list references --$ali_nodes, and$ali_types, respectively.By the optional parameter
$filter, one may specify a filter to be applied to the nodes and links. The filter is a hash reference, with the following possible keys:language- the language of the aligned nodes (e.g.en)selector- the selector of the aligned nodes (e.g.src)directed- return only the links originating from the$node(possible values:0and1, by default equals to1)rel_types- filter the alignment types. The value of this parameter must be a reference to a list of regular expression strings. The expressions starting with the!sign represent negative filters. The actual link type is compared to these regexps one after another, skipping the rest if the type matches a current regexp. If the type matches no regexps in the list, it is filtered out. Therefore, negative rules should be at the beginning of the list, followed by at least one positive rule. For instance,['^a$','^b$']returns only links of typeaorb. On the other hand,['!^a$','!^b$','.*']returns everything except foraandb. The filter['!^ab.*','^a.*']accepts only the types starting witha, except for those starting withab.For the time being,
directed = 1is the default if it is not specified in the filter. However, this will probably change soon, so you had better useget_directed_aligned_nodesfor this purpose, or specify thedirectedparameter, explicitly.Both returned list references --
$ali_nodesand$ali_types, are always defined. If the$nodehas no alignment link that satisfies the filter constraints, a reference to an empty list is returned. - ($ali_nodes, $ali_types) = $node->get_undirected_aligned_nodes($filter)
-
Return counterparts of the links in both the specified and opposite direction. It calls
get_aligned_nodeswithdirectedequal to 0. - ($ali_nodes, $ali_types) = $node->get_directed_aligned_nodes($filter)
-
Return only counterparts of the links in the specified direction. Calls
get_aligned_nodeswithdirectedequal to 1. With undefinedfilter, it corresponds to the original version of theget_aligned_nodesmethod. - my @nodes = $node->get_aligned_nodes_of_type($regex_constraint_on_type)
-
Returns a list of nodes aligned to the $node by the specified alignment type.
- my $is_aligned = $node1->is_aligned_to($node2, $filter)
-
An indicator function of whether the nodes
$node1and$node2are aligned under the conditions specified by the filter$filter(see more in theget_aligned_nodesfunction description). For the time being,directed = 1is the default if it is not specified in the filter. However, this will probably change soon, so you had better useis_directed_aligned_tofor this purpose, or specify thedirectedparameter, explicitly. - my $is_aligned = $node1->is_undirected_aligned_to($node2, $filter)
-
The same as
is_aligned_to, accepting links in both the specified and the opposite direction. - my $is_aligned = $node1->is_directed_aligned_to($node2, $filter)
-
The same as
is_aligned_to, accepting links only in the specified direction. - $node->delete_aligned_node($target, $type)
-
All alignments of the $target to $node are deleted, if their types equal $type.
- $node->delete_aligned_nodes_by_filter($filter)
-
This deletes the alignment links pointing from/to the node
$node. Only the links satisfying the$filterconstraints are removed. If the parameterdirectedin thefilteris not specified,directed = 0is the default. - $node->add_aligned_node($target, $type)
-
Aligns $target node to $node. The prior existence of the link is not checked.
- $node->update_aligned_nodes()
-
Removes all alignment links leading to nodes which have been deleted.
AUTHOR
Michal Novák <mnovak@ufal.mff.cuni.cz>
COPYRIGHT AND LICENSE
Copyright © 2015 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.