line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
##-*- Mode: CPerl -*- |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
##====================================================================== |
4
|
|
|
|
|
|
|
## top-level |
5
|
|
|
|
|
|
|
package DDC::PP::CQueryOptions; |
6
|
20
|
|
|
20
|
|
149
|
use DDC::PP::Constants; |
|
20
|
|
|
|
|
44
|
|
|
20
|
|
|
|
|
591
|
|
7
|
20
|
|
|
20
|
|
103
|
use DDC::PP::Object; |
|
20
|
|
|
|
|
41
|
|
|
20
|
|
|
|
|
368
|
|
8
|
20
|
|
|
20
|
|
94
|
use DDC::Utils qw(); |
|
20
|
|
|
|
|
40
|
|
|
20
|
|
|
|
|
319
|
|
9
|
20
|
|
|
20
|
|
115
|
use Carp qw(carp confess); |
|
20
|
|
|
|
|
67
|
|
|
20
|
|
|
|
|
1282
|
|
10
|
20
|
|
|
20
|
|
137
|
use strict; |
|
20
|
|
|
|
|
68
|
|
|
20
|
|
|
|
|
732
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
##====================================================================== |
13
|
|
|
|
|
|
|
## CQueryOptions |
14
|
|
|
|
|
|
|
package DDC::PP::CQueryOptions; |
15
|
20
|
|
|
20
|
|
126
|
use strict; |
|
20
|
|
|
|
|
45
|
|
|
20
|
|
|
|
|
18791
|
|
16
|
|
|
|
|
|
|
our @ISA = qw(DDC::PP::Object); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
__PACKAGE__->defprop($_) |
19
|
|
|
|
|
|
|
foreach (qw(ContextSentencesCount EnableBibliography DebugRank SeparateHits Filters Subcorpora Comments LexerComments)); #Within |
20
|
4
|
|
|
4
|
0
|
11
|
sub getWithin { return $_[0]{Within}; } |
21
|
2
|
50
|
|
2
|
0
|
14
|
sub setWithin { return $_[0]{Within} = UNIVERSAL::isa($_[1],'ARRAY') ? $_[1] : [$_[1]]; } |
22
|
|
|
|
|
|
|
__PACKAGE__->defalias('ContextCount'=>'ContextSentencesCount',0,1); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new { |
25
|
452
|
|
|
452
|
0
|
882
|
my ($that,%opts) = @_; |
26
|
452
|
|
|
|
|
1689
|
return $that->SUPER::new(EnableBibliography=>1,Filters=>[],Subcorpora=>[],Within=>[],Comments=>[],LexerComments=>[],%opts); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub swap { |
30
|
0
|
|
|
0
|
0
|
0
|
my ($a,$b) = @_; |
31
|
0
|
|
|
|
|
0
|
my %tmp = %$b; |
32
|
0
|
|
|
|
|
0
|
%$b = %$a; |
33
|
0
|
|
|
|
|
0
|
%$a = %tmp; |
34
|
0
|
|
|
|
|
0
|
return $a; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub Clear { |
38
|
0
|
|
|
0
|
0
|
0
|
@{$_[0]{Filters}} = @{$_[0]{Subcorpora}} = @{$_[0]{Comments}} = @{$_[0]{LexerComments}} = qw(); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
sub ClearComments { |
41
|
0
|
|
|
0
|
0
|
0
|
@{$_[0]{Comments}} = @{$_[0]{LexerComments}} = qw(); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__PACKAGE__->nomethod('CanFilterByFile'); |
45
|
|
|
|
|
|
|
|
46
|
0
|
0
|
|
0
|
0
|
0
|
sub Children { return [ @{$_[0]{Filters}||[]} ]; } |
|
0
|
|
|
|
|
0
|
|
47
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
0
|
0
|
0
|
sub sqString { return DDC::Utils::escapeq(defined($_[1]) ? $_[1] : ''); } |
49
|
|
|
|
|
|
|
sub toString { |
50
|
2
|
|
|
2
|
0
|
5
|
my $qo = shift; |
51
|
|
|
|
|
|
|
return ( |
52
|
0
|
|
|
|
|
0
|
($qo->{Within} ? join('', map {" #WITHIN ".$qo->sqString($_)} @{$qo->{Within}}) : '') |
|
2
|
|
|
|
|
25
|
|
53
|
|
|
|
|
|
|
.($qo->{ContextSentencesCount} ? " #CNTXT $qo->{ContextSentencesCount}" : '') |
54
|
|
|
|
|
|
|
.($qo->{SeparateHits} ? " #SEPARATE" : '') |
55
|
|
|
|
|
|
|
.(!$qo->{EnableBibliography} ? " #FILENAMES" : '') |
56
|
|
|
|
|
|
|
.($qo->{DebugRank} ? " #DEBUG_RANK" : '') |
57
|
0
|
50
|
|
|
|
0
|
.join('', map {" ".$_->toString} @{$qo->{Filters}||[]}) |
|
2
|
|
|
|
|
11
|
|
58
|
0
|
50
|
|
|
|
0
|
.join('', map {" #CMT ".$qo->sqString($_)} @{$qo->{Comments}||[]}) |
|
2
|
|
|
|
|
11
|
|
59
|
0
|
|
50
|
|
|
0
|
.join('', map {" $_"} @{$qo->{LexerComments}//[]}) |
|
2
|
|
|
|
|
29
|
|
60
|
2
|
50
|
33
|
|
|
7
|
.($qo->{Subcorpora} && @{$qo->{Subcorpora}} ? (" :".join(',', map {$qo->sqString($_)} @{$qo->{Subcorpora}})) : '') |
|
0
|
50
|
|
|
|
0
|
|
|
0
|
50
|
|
|
|
0
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
##-- ddc-compatible hash-conversion (for toJson()) |
65
|
|
|
|
|
|
|
sub toHash { |
66
|
198
|
|
|
198
|
0
|
446
|
my ($obj,%opts) = @_; |
67
|
198
|
100
|
|
|
|
485
|
return $obj->SUPER::toHash(%opts) if (!$opts{json}); |
68
|
196
|
|
|
|
|
526
|
return { class=>$obj->jsonClass, $obj->jsonData }; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
sub jsonData { |
71
|
196
|
|
|
196
|
0
|
319
|
my $qo = shift; |
72
|
|
|
|
|
|
|
return (($qo->{Within} && $qo->{Within} ? (Within=>$qo->{Within}) : qw()), |
73
|
|
|
|
|
|
|
($qo->{ContextSentencesCount} ? (ContextCount=>$qo->{ContextSentencesCount}) : qw()), |
74
|
|
|
|
|
|
|
($qo->{SeparateHits} ? (SeparateHits=>$qo->{SeparateHits}) : qw()), |
75
|
|
|
|
|
|
|
($qo->{EnableBibliography} ? (EnableBibliography=>$qo->{EnableBibliography}) : qw()), |
76
|
|
|
|
|
|
|
($qo->{DebugRank} ? (DebugRank=>$qo->{DebugRank}) : qw()), |
77
|
16
|
50
|
|
|
|
73
|
(Filters=>[map {($_->toHash(json=>1))} @{$qo->{Filters}||[]}]), |
|
196
|
|
|
|
|
758
|
|
78
|
|
|
|
|
|
|
($qo->{Subcorpora} && @{$qo->{Subcorpora}} ? (Subcorpora=>$qo->{Subcorpora}) : qw()), |
79
|
|
|
|
|
|
|
($qo->{Comments} && @{$qo->{Comments}} ? (Comments=>$qo->{Comments}) : qw()), |
80
|
196
|
50
|
33
|
|
|
1626
|
($qo->{LexerComments} && @{$qo->{LexerComments}} ? (LexerComments=>$qo->{LexerComments}) : qw()), |
|
|
50
|
66
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; ##-- be happy |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=pod |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 NAME |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
DDC::PP::CQueryOptions - pure-perl implementation of DDC::XS::CQueryOptions |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 SYNOPSIS |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
use DDC::PP::CQueryOptions; |
96
|
|
|
|
|
|
|
#... stuff happens ... |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 DESCRIPTION |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
The DDC::PP::CQueryOptions class is a pure-perl fork of the L class, |
102
|
|
|
|
|
|
|
which see for details. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 SEE ALSO |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
perl(1), |
107
|
|
|
|
|
|
|
DDC::PP(3perl), |
108
|
|
|
|
|
|
|
DDC::XS::CQueryOptions(3perl). |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 AUTHOR |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Bryan Jurish Emoocow@cpan.orgE |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Copyright (C) 2016-2020 by Bryan Jurish |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
119
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.14.2 or, |
120
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |
123
|
|
|
|
|
|
|
|