Treex::Core::Node::Aligned
version 2.20160630
Moose role with methods to access alignment.
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.
$node
$ali_nodes
$ali_types
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:
$filter
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: 0 and 1, by default equals to 1) 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 type a or b. On the other hand, ['!^a$','!^b$','.*'] returns everything except for a and b. The filter ['!^ab.*','^a.*'] accepts only the types starting with a, except for those starting with ab.
language
en
selector
src
directed
0
1
rel_types
!
['^a$','^b$']
a
b
['!^a$','!^b$','.*']
['!^ab.*','^a.*']
ab
For the time being, directed = 1 is the default if it is not specified in the filter. However, this will probably change soon, so you had better use get_directed_aligned_nodes for this purpose, or specify the directed parameter, explicitly.
directed = 1
get_directed_aligned_nodes
Both returned list references -- $ali_nodes and $ali_types, are always defined. If the $node has no alignment link that satisfies the filter constraints, a reference to an empty list is returned.
Return counterparts of the links in both the specified and opposite direction. It calls get_aligned_nodes with directed equal to 0.
get_aligned_nodes
Return only counterparts of the links in the specified direction. Calls get_aligned_nodes with directed equal to 1. With undefined filter, it corresponds to the original version of the get_aligned_nodes method.
filter
Returns a list of nodes aligned to the $node by the specified alignment type.
An indicator function of whether the nodes $node1 and $node2 are aligned under the conditions specified by the filter $filter (see more in the get_aligned_nodes function description). For the time being, directed = 1 is the default if it is not specified in the filter. However, this will probably change soon, so you had better use is_directed_aligned_to for this purpose, or specify the directed parameter, explicitly.
$node1
$node2
is_directed_aligned_to
The same as is_aligned_to, accepting links in both the specified and the opposite direction.
is_aligned_to
The same as is_aligned_to, accepting links only in the specified direction.
All alignments of the $target to $node are deleted, if their types equal $type.
This deletes the alignment links pointing from/to the node $node. Only the links satisfying the $filter constraints are removed. If the parameter directed in the filter is not specified, directed = 0 is the default.
directed = 0
Aligns $target node to $node. The prior existence of the link is not checked.
Removes all alignment links leading to nodes which have been deleted.
Michal Novák <mnovak@ufal.mff.cuni.cz>
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.
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.