| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Treex::Core::Common; |
|
2
|
|
|
|
|
|
|
$Treex::Core::Common::VERSION = '2.20160630'; |
|
3
|
27
|
|
|
27
|
|
21617
|
use strict; |
|
|
27
|
|
|
|
|
74
|
|
|
|
27
|
|
|
|
|
808
|
|
|
4
|
27
|
|
|
27
|
|
142
|
use warnings; |
|
|
27
|
|
|
|
|
59
|
|
|
|
27
|
|
|
|
|
713
|
|
|
5
|
27
|
|
|
27
|
|
669
|
use 5.010; |
|
|
27
|
|
|
|
|
101
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
27
|
|
|
27
|
|
13816
|
use utf8; |
|
|
27
|
|
|
|
|
356
|
|
|
|
27
|
|
|
|
|
175
|
|
|
8
|
27
|
|
|
27
|
|
1217
|
use Moose::Exporter; |
|
|
27
|
|
|
|
|
136241
|
|
|
|
27
|
|
|
|
|
203
|
|
|
9
|
27
|
|
|
27
|
|
1625
|
use Moose::Util::TypeConstraints; |
|
|
27
|
|
|
|
|
132998
|
|
|
|
27
|
|
|
|
|
248
|
|
|
10
|
27
|
|
|
27
|
|
65216
|
use MooseX::SemiAffordanceAccessor::Role::Attribute 0.09; |
|
|
27
|
|
|
|
|
465688
|
|
|
|
27
|
|
|
|
|
1045
|
|
|
11
|
27
|
|
|
27
|
|
13390
|
use Treex::Core::Log; |
|
|
27
|
|
|
|
|
134
|
|
|
|
27
|
|
|
|
|
2498
|
|
|
12
|
27
|
|
|
27
|
|
17169
|
use Treex::Core::Config; |
|
|
27
|
|
|
|
|
96
|
|
|
|
27
|
|
|
|
|
932
|
|
|
13
|
27
|
|
|
27
|
|
11264
|
use Treex::Core::Resource; |
|
|
27
|
|
|
|
|
93
|
|
|
|
27
|
|
|
|
|
1250
|
|
|
14
|
27
|
|
|
27
|
|
11386
|
use Treex::Core::Types; |
|
|
27
|
|
|
|
|
145
|
|
|
|
27
|
|
|
|
|
1516
|
|
|
15
|
27
|
|
|
27
|
|
14073
|
use Treex::Core::Files; |
|
|
27
|
|
|
|
|
134
|
|
|
|
27
|
|
|
|
|
1224
|
|
|
16
|
27
|
|
|
27
|
|
15576
|
use List::MoreUtils; |
|
|
27
|
|
|
|
|
178778
|
|
|
|
27
|
|
|
|
|
326
|
|
|
17
|
27
|
|
|
27
|
|
16023
|
use List::Util; |
|
|
27
|
|
|
|
|
73
|
|
|
|
27
|
|
|
|
|
1668
|
|
|
18
|
27
|
|
|
27
|
|
173
|
use Scalar::Util; |
|
|
27
|
|
|
|
|
66
|
|
|
|
27
|
|
|
|
|
914
|
|
|
19
|
27
|
|
|
27
|
|
153
|
use Readonly; |
|
|
27
|
|
|
|
|
72
|
|
|
|
27
|
|
|
|
|
1201
|
|
|
20
|
27
|
|
|
27
|
|
15692
|
use Data::Dumper; |
|
|
27
|
|
|
|
|
129232
|
|
|
|
27
|
|
|
|
|
10206
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# sub reference for validating of params |
|
23
|
|
|
|
|
|
|
# Sets default values for unspecified params |
|
24
|
|
|
|
|
|
|
my $validation_sub; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Quick alternative for MooseX::Params::Validate::pos_validated_list |
|
27
|
|
|
|
|
|
|
sub pos_validated_list { |
|
28
|
0
|
|
|
0
|
1
|
0
|
my $args_ref = shift; |
|
29
|
0
|
|
|
|
|
0
|
my @args = @{$args_ref}; |
|
|
0
|
|
|
|
|
0
|
|
|
30
|
0
|
|
|
|
|
0
|
my $i = 0; |
|
31
|
0
|
|
|
|
|
0
|
while ( ref $_[0] eq 'HASH' ) { |
|
32
|
0
|
|
|
|
|
0
|
my $spec = shift; |
|
33
|
0
|
0
|
|
|
|
0
|
if ( defined $spec->{default} ) { |
|
34
|
0
|
|
0
|
|
|
0
|
$args[$i] //= $spec->{default}; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
0
|
|
|
|
|
0
|
$i++; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
0
|
|
|
|
|
0
|
return @args; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Choose which variant to use according to $Treex::Core::Config::params_validate |
|
42
|
|
|
|
|
|
|
if ( $Treex::Core::Config::params_validate == 2 ) { ## no critic (ProhibitPackageVars) |
|
43
|
|
|
|
|
|
|
require MooseX::Params::Validate; |
|
44
|
|
|
|
|
|
|
$validation_sub = \&MooseX::Params::Validate::pos_validated_list; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
else { |
|
47
|
|
|
|
|
|
|
$validation_sub = \&pos_validated_list; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my ( $import, $unimport, $init_meta ) = |
|
51
|
|
|
|
|
|
|
Moose::Exporter->build_import_methods( |
|
52
|
|
|
|
|
|
|
install => [qw(unimport init_meta)], |
|
53
|
|
|
|
|
|
|
class_metaroles => { attribute => ['MooseX::SemiAffordanceAccessor::Role::Attribute'] }, |
|
54
|
|
|
|
|
|
|
as_is => [ |
|
55
|
|
|
|
|
|
|
\&Treex::Core::Log::log_fatal, |
|
56
|
|
|
|
|
|
|
\&Treex::Core::Log::log_warn, |
|
57
|
|
|
|
|
|
|
\&Treex::Core::Log::log_debug, |
|
58
|
|
|
|
|
|
|
\&Treex::Core::Log::log_set_error_level, |
|
59
|
|
|
|
|
|
|
\&Treex::Core::Log::log_info, |
|
60
|
|
|
|
|
|
|
\&Treex::Core::Types::get_lang_name, |
|
61
|
|
|
|
|
|
|
\&Treex::Core::Types::is_lang_code, |
|
62
|
|
|
|
|
|
|
\&Treex::Core::Resource::require_file_from_share, |
|
63
|
|
|
|
|
|
|
\&List::MoreUtils::first_index, |
|
64
|
|
|
|
|
|
|
\&List::MoreUtils::all, |
|
65
|
|
|
|
|
|
|
\&List::MoreUtils::any, |
|
66
|
|
|
|
|
|
|
\&List::MoreUtils::none, |
|
67
|
|
|
|
|
|
|
\&List::MoreUtils::uniq, |
|
68
|
|
|
|
|
|
|
\&List::Util::first, |
|
69
|
|
|
|
|
|
|
\&List::Util::min, |
|
70
|
|
|
|
|
|
|
\&List::Util::max, |
|
71
|
|
|
|
|
|
|
\&Readonly::Readonly, |
|
72
|
|
|
|
|
|
|
\&Scalar::Util::weaken, |
|
73
|
|
|
|
|
|
|
\&Data::Dumper::Dumper, |
|
74
|
|
|
|
|
|
|
\&Moose::Util::TypeConstraints::enum, |
|
75
|
|
|
|
|
|
|
$validation_sub, |
|
76
|
|
|
|
|
|
|
] |
|
77
|
|
|
|
|
|
|
); |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub import { |
|
80
|
111
|
|
|
111
|
|
9105
|
feature->import(':5.10'); |
|
81
|
111
|
|
|
|
|
733
|
utf8::import(); |
|
82
|
111
|
|
|
|
|
913
|
goto &$import; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__END__ |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=encoding utf-8 |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 NAME |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Treex::Core::Common - shorten the "C<use>" part of your Perl codes |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 VERSION |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
version 2.20160630 |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Write just |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
use Treex::Core::Common; |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Instead of |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
use utf8; |
|
108
|
|
|
|
|
|
|
use strict; |
|
109
|
|
|
|
|
|
|
use warnings; |
|
110
|
|
|
|
|
|
|
use Moose::Util::TypeConstraints qw(enum); |
|
111
|
|
|
|
|
|
|
use MooseX::SemiAffordanceAccessor; |
|
112
|
|
|
|
|
|
|
use MooseX::Params::Validate qw(pos_validated_list); |
|
113
|
|
|
|
|
|
|
use Treex::Core::Log; |
|
114
|
|
|
|
|
|
|
use Treex::Core::Config; |
|
115
|
|
|
|
|
|
|
use Treex::Core::Resource; |
|
116
|
|
|
|
|
|
|
use Treex::Core::Types; |
|
117
|
|
|
|
|
|
|
use Treex::Core::Files; |
|
118
|
|
|
|
|
|
|
use List::MoreUtils qw(all any none uniq first_index); |
|
119
|
|
|
|
|
|
|
use List::Util qw(first min max); |
|
120
|
|
|
|
|
|
|
use Scalar::Util qw(weaken); |
|
121
|
|
|
|
|
|
|
use Readonly qw(Readonly); |
|
122
|
|
|
|
|
|
|
use Data::Dumper qw(Dumper); |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 SUBROUTINES |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=over |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item $language_name = get_lang_name($iso639_code) |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item $bool = is_lang_code($iso639_code) |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item pos_validated_list |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
This subroutine is automatically exported. Depending on the value of |
|
136
|
|
|
|
|
|
|
L<$Treex::Core::Config::params_validate|Treex::Core::Config/params_validate> |
|
137
|
|
|
|
|
|
|
it is either the (slow) one from |
|
138
|
|
|
|
|
|
|
L<MooseX::Params::Validate> or a fast one, that does |
|
139
|
|
|
|
|
|
|
no type checking. |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=back |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 AUTHOR |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Martin Popel <popel@ufal.mff.cuni.cz> |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Copyright © 2011 by Institute of Formal and Applied Linguistics, Charles University in Prague |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |