The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

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: 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.

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.

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.

($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_nodes with directed equal 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_nodes with directed equal to 1. With undefined filter, it corresponds to the original version of the get_aligned_nodes method.

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 $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.

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 $filter constraints are removed. If the parameter directed in the filter is not specified, directed = 0 is 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.