File Coverage

blib/lib/Treex/Core/Node/N.pm
Criterion Covered Total %
statement 20 20 100.0
branch 3 4 75.0
condition n/a
subroutine 6 6 100.0
pod 3 3 100.0
total 32 33 96.9


line stmt bran cond sub pod time code
1             package Treex::Core::Node::N;
2             $Treex::Core::Node::N::VERSION = '2.20210102';
3 24     24   209 use namespace::autoclean;
  24         62  
  24         348  
4              
5 24     24   2516 use Moose;
  24         69  
  24         187  
6 24     24   176693 use Treex::Core::Common;
  24         66  
  24         289  
7             extends 'Treex::Core::Node';
8              
9             has [qw(ne_type normalized_name)] => ( is => 'rw' );
10              
11             sub get_pml_type_name {
12 24     24 1 53 my ($self) = @_;
13 24 100       66 return $self->is_root() ? 'n-root.type' : 'n-node.type';
14             }
15              
16             override '_get_reference_attrs' => sub {
17             my ($self) = @_;
18             return ('a.rf');
19             };
20              
21              
22             sub get_anodes {
23 3     3 1 11 my ($self) = @_;
24 3 50       16 my $ids_ref = $self->get_attr('a.rf') or return;
25 3         15 my $doc = $self->get_document();
26 3         9 return map { $doc->get_node_by_id($_) } @{$ids_ref};
  5         24  
  3         10  
27             }
28              
29             sub set_anodes {
30 1     1 1 9 my $self = shift;
31 1         5 return $self->set_attr( 'a.rf', [ map { $_->id } @_ ] );
  2         54  
32             }
33              
34             1;
35              
36             __END__
37              
38             =encoding utf-8
39              
40             =head1 NAME
41              
42             Treex::Core::Node::N
43              
44             =head1 VERSION
45              
46             version 2.20210102
47              
48             =head1 DESCRIPTION
49              
50             A node for storing named entities.
51              
52             =head1 ATTRIBUTES
53              
54             =over
55              
56             =item ne_type
57              
58             Type of the named entity (string).
59              
60             =item normalized_name
61              
62             E.g. for "N.Y." this can be "New York".
63              
64             =back
65              
66             =head1 METHODS
67              
68             =over
69              
70             =item get_anodes
71              
72             Return a-nodes referenced by (or corresponding to) this n-node.
73              
74             =item set_anodes(@anodes)
75              
76             Set a-nodes to be referenced by (or corresponding to) this n-node.
77              
78             =back
79              
80             =head1 AUTHOR
81              
82             Martin Popel <popel@ufal.mff.cuni.cz>
83              
84             =head1 COPYRIGHT AND LICENSE
85              
86             Copyright © 2011-2012 by Institute of Formal and Applied Linguistics, Charles University in Prague
87              
88             This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.