| 1 | package Treex::Core::BundleZone; | ||||||||||||||||||||||||||||
| 2 | { | ||||||||||||||||||||||||||||
| 3 | 59 | $Treex::Core::BundleZone::VERSION = '0.08633_1'; | |||||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 59 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 59 | ▶ | use Treex::Core::Common; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 59 | ▶ | use MooseX::NonMoose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 59 | ▶ | use Treex::Core::Node::A; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 59 | ▶ | use Treex::Core::Node::T; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 59 | ▶ | use Treex::Core::Node::N; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 59 | ▶ | use Treex::Core::Node::P; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 59 | extends 'Treex::Core::Zone'; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | sub _set_bundle { | ||||||||||||||||||||||||||||
| 18 | 34 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_set_bundle: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 34 | my ($bundle) = pos_validated_list( | |||||||||||||||||||||||||||
| 20 | \@_, | ||||||||||||||||||||||||||||
| 21 | { isa => 'Treex::Core::Bundle' }, | ||||||||||||||||||||||||||||
| 22 | ); | ||||||||||||||||||||||||||||
| 23 | 34 | $self->set_attr( '_bundle', $bundle ); | |||||||||||||||||||||||||||
| 24 | 34 | weaken $self->{'_bundle'}; | |||||||||||||||||||||||||||
| 25 | 34 | return; | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | sub get_bundle { | ||||||||||||||||||||||||||||
| 29 | 736 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get_bundle: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 30 | 736 | return $self->get_attr('_bundle'); | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | sub get_document { | ||||||||||||||||||||||||||||
| 34 | 96 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get_document: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 35 | 96 | return $self->get_bundle->get_document; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | sub create_atree { | ||||||||||||||||||||||||||||
| 39 | 8 | ▶ | my ($self,$params_rf) = @_; | ||||||||||||||||||||||||||
|
Subroutine
create_atree: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 40 | 8 | return $self->create_tree('a',$params_rf); | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | sub create_ttree { | ||||||||||||||||||||||||||||
| 44 | 8 | ▶ | my ($self,$params_rf) = @_; | ||||||||||||||||||||||||||
|
Subroutine
create_ttree: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 45 | 8 | return $self->create_tree('t',$params_rf); | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | sub create_ntree { | ||||||||||||||||||||||||||||
| 49 | 4 | ▶ | my ($self,$params_rf) = @_; | ||||||||||||||||||||||||||
|
Subroutine
create_ntree: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 50 | 4 | return $self->create_tree('n',$params_rf); | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | sub create_ptree { | ||||||||||||||||||||||||||||
| 54 | 4 | ▶ | my ($self,$params_rf) = @_; | ||||||||||||||||||||||||||
|
Subroutine
create_ptree: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 55 | 4 | return $self->create_tree('p',$params_rf); | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | sub create_tree { | ||||||||||||||||||||||||||||
| 59 | 57 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
create_tree: called CC=9 SCAR=22.2
Pod
documented
| |||||||||||||||||||||||||||||
| 60 | 57 | my ($layer,$params_rf) = pos_validated_list( | |||||||||||||||||||||||||||
| 61 | \@_, | ||||||||||||||||||||||||||||
| 62 | { isa => 'Treex::Type::Layer' }, | ||||||||||||||||||||||||||||
| 63 | { isa => 'Ref' }, | ||||||||||||||||||||||||||||
| 64 | ); | ||||||||||||||||||||||||||||
| 65 | 57 | $layer = lc $layer; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 57 | ▶ | if ($self->has_tree($layer)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 12 | ▶ | if (defined $params_rf and $params_rf->{overwrite}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $params_rf and $params_rf->{"overwrite"}
MC/DC0%0/2
defined $params_rf and $params_rf->{"overwrite"}
defined $params_rf
$params_rf->{"overwrite"}
Truth table33%1/3
A and B
A= defined $params_rfB= $params_rf->{"overwrite"}
| |||||||||||||||||||||||||||||
| 69 | 12 | $self->remove_tree($layer); | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | else { | ||||||||||||||||||||||||||||
| 72 | 0 | log_fatal("Zone already contains tree at $layer layer"); | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | #my $class = "Treex::Core::Node::" . uc($layer); | ||||||||||||||||||||||||||||
| 77 | #my $tree_root = eval { $class->new( { _called_from_core_ => 1 } ) } or log_fatal $!; #layer subclasses not available yet | ||||||||||||||||||||||||||||
| 78 | 57 | my $opts = { _called_from_core_ => 1 }; | |||||||||||||||||||||||||||
| 79 | 57 | ▶ | my $tree_root = $layer eq 'a' ? Treex::Core::Node::A->new($opts) | ||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 80 | : $layer eq 't' ? Treex::Core::Node::T->new($opts) | ||||||||||||||||||||||||||||
| 81 | : $layer eq 'n' ? Treex::Core::Node::N->new($opts) | ||||||||||||||||||||||||||||
| 82 | : $layer eq 'p' ? Treex::Core::Node::P->new($opts) | ||||||||||||||||||||||||||||
| 83 | : log_fatal "Cannot create tree for unknown layer $layer"; | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 57 | my $bundle = $self->get_bundle; | |||||||||||||||||||||||||||
| 86 | 57 | $tree_root->_set_zone($self); | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 57 | my $new_tree_name = $layer . "_tree"; | |||||||||||||||||||||||||||
| 89 | 57 | $self->{trees}->{$new_tree_name} = $tree_root; | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 57 | my $new_id = "$new_tree_name-" . $self->get_label . "-" . $bundle->get_id . "-root"; | |||||||||||||||||||||||||||
| 92 | 57 | $tree_root->set_id($new_id); | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | # pml-typing | ||||||||||||||||||||||||||||
| 95 | #$tree_root->set_type_by_name( $self->get_document->metaData('schema'), lc($layer) . '-root.type' ); | ||||||||||||||||||||||||||||
| 96 | 57 | $tree_root->set_type_by_name( $self->get_document->metaData('schema'), $tree_root->get_pml_type_name() ); | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | # vyresit usporadavaci atribut! | ||||||||||||||||||||||||||||
| 99 | # TODO: if $tree_root->does('Treex::Core::Role::OrderedTree') | ||||||||||||||||||||||||||||
| 100 | 57 | my $ordering_attribute = $tree_root->get_ordering_member_name; | |||||||||||||||||||||||||||
| 101 | 57 | ▶ | if ( defined $ordering_attribute ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | 33 | $tree_root->set_attr( $ordering_attribute, 0 ); | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 57 | return $tree_root; | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | sub remove_tree { | ||||||||||||||||||||||||||||
| 109 | 39 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
remove_tree: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 110 | 39 | my ($layer) = pos_validated_list( | |||||||||||||||||||||||||||
| 111 | \@_, | ||||||||||||||||||||||||||||
| 112 | { isa => 'Treex::Type::Layer' }, | ||||||||||||||||||||||||||||
| 113 | ); | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | # remove all nodes ($tree_root->remove does not work, in order to not be used by users) | ||||||||||||||||||||||||||||
| 116 | 39 | my $tree_root = $self->get_tree($layer); | |||||||||||||||||||||||||||
| 117 | 39 | foreach my $child ( $tree_root->get_children() ) { | |||||||||||||||||||||||||||
| 118 | 4 | $child->remove(); | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | 39 | ▶ | if ( $tree_root->id ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 121 | 39 | $self->get_document->index_node_by_id( $tree_root->id, undef ); | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | 39 | delete $self->{trees}{ lc($layer) . '_tree' }; | |||||||||||||||||||||||||||
| 124 | 39 | return; | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | sub get_tree { | ||||||||||||||||||||||||||||
| 128 | 105 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get_tree: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 129 | 105 | my ($layer) = pos_validated_list( | |||||||||||||||||||||||||||
| 130 | \@_, | ||||||||||||||||||||||||||||
| 131 | { isa => 'Treex::Type::Layer' }, | ||||||||||||||||||||||||||||
| 132 | ); | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 105 | my $tree_name = lc($layer) . "_tree"; | |||||||||||||||||||||||||||
| 135 | 105 | my $tree = $self->{trees}->{$tree_name}; | |||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | 105 | ▶ | if ( not defined $tree ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | 0 | log_fatal( "No $tree_name available in the bundle, bundle id=" . $self->get_attr('id') ); | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | 105 | return $tree; | |||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | sub get_atree { | ||||||||||||||||||||||||||||
| 144 | 9 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get_atree: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 145 | 9 | return $self->get_tree('a'); | |||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | sub get_ttree { | ||||||||||||||||||||||||||||
| 149 | 9 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get_ttree: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 150 | 9 | return $self->get_tree('t'); | |||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | sub get_ntree { | ||||||||||||||||||||||||||||
| 154 | 7 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get_ntree: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 155 | 7 | return $self->get_tree('n'); | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | sub get_ptree { | ||||||||||||||||||||||||||||
| 159 | 6 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get_ptree: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 160 | 6 | return $self->get_tree('p'); | |||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | sub has_tree { | ||||||||||||||||||||||||||||
| 164 | 109 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
has_tree: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 165 | 109 | my ($layer) = pos_validated_list( | |||||||||||||||||||||||||||
| 166 | \@_, | ||||||||||||||||||||||||||||
| 167 | { isa => 'Treex::Type::Layer' }, | ||||||||||||||||||||||||||||
| 168 | ); | ||||||||||||||||||||||||||||
| 169 | 109 | my $tree_name = lc($layer) . "_tree"; | |||||||||||||||||||||||||||
| 170 | 109 | return defined $self->{trees}->{$tree_name}; | |||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | sub has_atree { | ||||||||||||||||||||||||||||
| 174 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
has_atree: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 175 | 3 | return $self->has_tree('a'); | |||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | sub has_ttree { | ||||||||||||||||||||||||||||
| 179 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
has_ttree: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 180 | 3 | return $self->has_tree('t'); | |||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | sub has_ntree { | ||||||||||||||||||||||||||||
| 184 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
has_ntree: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 185 | 3 | return $self->has_tree('n'); | |||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | sub has_ptree { | ||||||||||||||||||||||||||||
| 189 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
has_ptree: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 190 | 3 | return $self->has_tree('p'); | |||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | sub get_all_trees { | ||||||||||||||||||||||||||||
| 194 | 176 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get_all_trees: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 704 | return grep {defined} | |||||||||||||||||||||||||||
| 197 | 176 | map { $self->{trees}->{ $_ . "_tree" }; } qw(a t n p); | |||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | sub sentence { | ||||||||||||||||||||||||||||
| 201 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
sentence: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 202 | 0 | return $self->get_attr('sentence'); | |||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | sub set_sentence { | ||||||||||||||||||||||||||||
| 206 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
set_sentence: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 207 | 0 | my ($text) = pos_validated_list( | |||||||||||||||||||||||||||
| 208 | \@_, | ||||||||||||||||||||||||||||
| 209 | { isa => 'Str' }, | ||||||||||||||||||||||||||||
| 210 | ); | ||||||||||||||||||||||||||||
| 211 | 0 | return $self->set_attr( 'sentence', $text ); | |||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | sub copy { | ||||||||||||||||||||||||||||
| 215 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
copy: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 216 | 0 | my $selector1 = shift; | |||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | # Get the bundle the zone is in. | ||||||||||||||||||||||||||||
| 219 | 0 | my $bundle = $self->get_bundle(); | |||||||||||||||||||||||||||
| 220 | 0 | my $zone1 = $bundle->get_or_create_zone( $self->language(), $selector1 ); | |||||||||||||||||||||||||||
| 221 | ### TO DO: copy other trees, too (currently only copies a-tree and p-tree) | ||||||||||||||||||||||||||||
| 222 | 0 | ▶ | if($self->has_atree()) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 223 | { | ||||||||||||||||||||||||||||
| 224 | 0 | my $aroot0 = $self->get_atree(); | |||||||||||||||||||||||||||
| 225 | 0 | my $aroot1 = $zone1->create_atree(); | |||||||||||||||||||||||||||
| 226 | 0 | $aroot0->copy_atree($aroot1); | |||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||
| 228 | 0 | ▶ | if($self->has_ptree()) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 229 | { | ||||||||||||||||||||||||||||
| 230 | 0 | my $proot0 = $self->get_ptree(); | |||||||||||||||||||||||||||
| 231 | 0 | my $proot1 = $zone1->create_ptree(); | |||||||||||||||||||||||||||
| 232 | 0 | $proot0->copy_ptree($proot1); | |||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | 0 | return $zone1; | |||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | 59 | 1; | |||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | __END__ | ||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | =for Pod::Coverage set_sentence | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | =encoding utf-8 | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | =head1 NAME | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | Treex::Core::BundleZone - contains a sentence and its linguistic representations | ||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | =head1 VERSION | ||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | version 0.08633_1 | ||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | use Treex::Core; | ||||||||||||||||||||||||||||
| 256 | my $doc = Treex::Core->new; | ||||||||||||||||||||||||||||
| 257 | my $bundle = $doc->create_bundle(); | ||||||||||||||||||||||||||||
| 258 | my $zone = $bundle->create_zone('en','reference'); | ||||||||||||||||||||||||||||
| 259 | $zone->set_sentence('John loves Mary.'); | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | Document zones allow Treex documents to contain more texts, | ||||||||||||||||||||||||||||
| 265 | typically parallel texts (translations), or corresponding | ||||||||||||||||||||||||||||
| 266 | texts from different sources (text to be translated, reference | ||||||||||||||||||||||||||||
| 267 | translation, test translation). | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | C<Treex::Core::BundleZone> instances have the following attributes: | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | =over 4 | ||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | =item language | ||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | =item selector | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | =item sentence | ||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | =back | ||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | The attributes can be accessed using semi-affordance accessors: getters have | ||||||||||||||||||||||||||||
| 284 | the same names as attributes, while setters start with C<set_>. For example, | ||||||||||||||||||||||||||||
| 285 | the attribute C<sentence> has a getter C<sentence()> and a setter | ||||||||||||||||||||||||||||
| 286 | C<set_sentence($sentence)> | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | =head1 METHODS | ||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | =head2 Construction | ||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | C<Treex::Core::BundleZone> instances should not be created by the constructor, | ||||||||||||||||||||||||||||
| 294 | but should be created exclusively by calling one of the following methods | ||||||||||||||||||||||||||||
| 295 | of the embedding L<Treex::Core::Bundle> instance: | ||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | =over 4 | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | =item create_zone | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | =item get_or_create_zone | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | =back | ||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | =head2 Access to trees | ||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | There are four types of linguistic trees distinguished in Treex, each of them represented | ||||||||||||||||||||||||||||
| 309 | by one letter: I<a> - analytical treex, I<t> - tectogrammatical trees, I<p> - phrase-structure trees, | ||||||||||||||||||||||||||||
| 310 | I<n> - named entity trees. You can create trees by following methods: | ||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | =over 4 | ||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | =item $zone->create_tree($layer); | ||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | =item $zone->create_atree(); | ||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | =item $zone->create_ttree(); | ||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | =item $zone->create_ptree(); | ||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | =item $zone->create_ntree(); | ||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | =back | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | You can access trees by | ||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | =over 4 | ||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | =item $zone->get_tree($layer); | ||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | =item $zone->get_atree(); | ||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||
| 335 | =item $zone->get_ttree(); | ||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | =item $zone->get_ptree(); | ||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | =item $zone->get_ntree(); | ||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | =item $zone->get_all_trees(); | ||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | =back | ||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | Presence of a tree of a certain type can be detected by | ||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | =over 4 | ||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | =item $zone->has_tree($layer); | ||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | =item $zone->has_atree(); | ||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | =item $zone->has_ttree(); | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | =item $zone->has_ptree(); | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | =item $zone->has_ntree(); | ||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||
| 360 | =back | ||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | You can remove trees by | ||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||
| 365 | =over 4 | ||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||
| 367 | =item $zone->remove_tree($layer); | ||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | =back | ||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | =head2 Access to embedding objects | ||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | =over 4 | ||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | =item $bundle = $zone->get_bundle(); | ||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | returns the L<Treex::Core::Bundle> instance which the zone belongs to | ||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | =item $doc = $zone->get_document(); | ||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | returns the L<Treex::Core::Document> instance which the zone belongs to | ||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | =back | ||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||
| 387 | =head2 Other | ||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | =over 4 | ||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||
| 391 | =item $zone1 = $zone0->copy($selector1); | ||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||
| 393 | creates a copy of the zone (currently copies only the a-tree) under the same language and a new selector | ||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | =back | ||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||
| 397 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | Zdeněk Žabokrtský <zabokrtsky@ufal.mff.cuni.cz> | ||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||
| 401 | Martin Popel <popel@ufal.mff.cuni.cz> | ||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | Copyright © 2011 by Institute of Formal and Applied Linguistics, Charles University in Prague | ||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||