Lemur/Database.pm

filter: Statementstmt 52.7% 19 / 36 Branchbran 50.0% 2 / 4 Conditioncond 76.1% 16 / 21 MC/DCmcdc 37.5% 3 / 8 Subroutinesub 33.3% 4 / 12 Podpod 100% 9 / 9 totaltotal 58.8% 53 / 90 CC 10 SCAR 16.7
CC
10
Cov
61%
equals
9.9
_new
2.0
num
2.0
CRAP 5.3
↑ Summary Lemur.pm »
1 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Search::Lemur::Database;
5  
6  
7  
8 =head1 NAME
9  
10 Lemur::Database
11  
12 =head1 VERSION
13  
14 Version 1.0
15  
16 =cut
17  
18 6 our $VERSION = '1.00';
19  
20  
21 =head1 DESCRIPTION
22  
23 Represent information about an available database.
24  
25  
26 =cut
27  
28 =head2 Main Methods
29  
30 =over 2
31  
32 =cut
33  
34 # create a new C<Database> object. This should only be called by a
35 # Lemur object, in its _makedbs method. One of these will be created
36 # for every database available to the Lemur server.
37 #
38 # The arguments are database number, title, stop status, stem status,
39 # number of docs, number of terms, number of unique terms, average
40 # document length. The stop status and stem status
41 # are one of 1 or 0, for true and false, respectively.
42 #
43 # If these arguments are not given, this will return undef
44 9 ▶sub _new {
Subroutine _new: called CC=2 SCAR=7.1
45 9 my $class = shift;
46 9 my $self = {};
47 9 ▶ if (scalar(@_) >= 8) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_ >= 8) { } 9 0 9
48 9 my ($num, $title, $stop, $stem, $numdocs, $numterms, $numuniq, $avgdoclen) = @_;
49 9 $self = { num => $num,
50 title => $title,
51 stop => $stop,
52 stem => $stem,
53 numdocs => $numdocs,
54 numterms => $numterms,
55 numuniq => $numuniq,
56 avgdoclen => $avgdoclen };
57 0 } else { return undef; }
58 9 bless $self, $class;
59 9 return $self;
60 }
61  
62 =item num()
63  
64 Get the database number. This number is useful to pass to
65 Lemur->d() to specify which database you want to use.
66  
67 =cut
68  
69 0 ▶sub num {
Subroutine num: not called CC=1 SCAR=6.9
Pod documented
70 0 my $self = shift;
71 0 return $self->{num};
72 }
73  
74  
75 =item title()
76  
77 Get the title of this database.
78  
79 =cut
80  
81 0 ▶sub title {
Subroutine title: not called CC=1 SCAR=6.9
Pod documented
82 0 my $self = shift;
83 0 return $self->{title};
84 }
85  
86 =item stem()
87  
88 Gets the stemming status of this database. Returns 1 if the
89 database is stemmed, 0 if not.
90  
91 =cut
92  
93 0 ▶sub stem {
Subroutine stem: not called CC=1 SCAR=6.9
Pod documented
94 0 my $self = shift;
95 0 return $self->{stem};
96 }
97  
98  
99 =item stop()
100  
101 Returns the stop word status of this database. Returns 1 if
102 the database is stop-worded, 0 if not.
103  
104 =cut
105  
106 0 ▶sub stop {
Subroutine stop: not called CC=1 SCAR=6.9
Pod documented
107 0 my $self = shift;
108 0 return $self->{stop};
109 }
110  
111  
112  
113 =item numdocs()
114  
115 Returns the number of documents in this database.
116  
117 =cut
118  
119 0 ▶sub numdocs {
Subroutine numdocs: not called CC=1 SCAR=6.9
Pod documented
120 0 my $self = shift;
121 0 return $self->{numdocs};
122 }
123  
124  
125  
126  
127 =item numterms()
128  
129 Returns the number of terms in this database.
130  
131 =cut
132  
133 0 ▶sub numterms {
Subroutine numterms: not called CC=1 SCAR=6.9
Pod documented
134 0 my $self = shift;
135 0 return $self->{numterms};
136 }
137  
138  
139  
140 =item numuniq()
141  
142 Returns the number of unique terms in this database.
143  
144 =cut
145  
146 0 ▶sub numuniq {
Subroutine numuniq: not called CC=1 SCAR=6.9
Pod documented
147 0 my $self = shift;
148 0 return $self->{numuniq};
149 }
150  
151  
152  
153  
154 =item avgdoclen()
155  
156 Returns the average document length in this database.
157  
158 =cut
159  
160 0 ▶sub avgdoclen {
Subroutine avgdoclen: not called CC=1 SCAR=6.9
Pod documented
161 0 my $self = shift;
162 0 return $self->{avgdoclen};
163 }
164  
165  
166  
167 =item equals
168  
169 Test equality between this database and the given one (used mostly for
170 testing).
171  
172 =cut
173  
174 5 ▶sub equals {
Subroutine equals: called CC=9 SCAR=22.9
Pod documented
175 5 my $self = shift;
176 5 my $other = shift;
177 5 ▶ return 0 unless ($other->isa('Search::Lemur::Database'));
Branch: 1 branch
BranchTrueFalseTotal
unless $other->isa("Search::Lemur::Database") 0 5 5
178 return ($self->{title} eq $other->{title}) &&
179 ($self->{num} == $other->{num}) &&
180 ($self->{stem} == $other->{stem}) &&
181 ($self->{stop} == $other->{stop}) &&
182 ($self->{numdocs} == $other->{numdocs}) &&
183 ($self->{numuniq} == $other->{numuniq}) &&
184 ($self->{avgdoclen} == $other->{avgdoclen}) &&
185 5 ▶ ($self->{numterms} == $other->{numterms});
Condition76%16/21
$self->{'title'} eq $other->{'title'} && $self->{'num'} == $other->{'num'} && $self->{'stem'} == $other->{'stem'} && $self->{'stop'} == $other->{'stop'} && $self->{'numdocs'} == $other->{'numdocs'} && $self->{'numuniq'} == $other->{'numuniq'} && $self->{'avgdoclen'} == $other->{'avgdoclen'} && $self->{'numterms'} == $other->{'numterms'}
!ll&&!rl&&r
302
$self->{"title"} eq $other->{"title"} and $self->{"num"} == $other->{"num"} and $self->{"stem"} == $other->{"stem"} and $self->{"stop"} == $other->{"stop"} and $self->{"numdocs"} == $other->{"numdocs"} and $self->{"numuniq"} == $other->{"numuniq"} and $self->{"avgdoclen"} == $other->{"avgdoclen"}
!ll&&!rl&&r
302
$self->{"title"} eq $other->{"title"} and $self->{"num"} == $other->{"num"} and $self->{"stem"} == $other->{"stem"} and $self->{"stop"} == $other->{"stop"} and $self->{"numdocs"} == $other->{"numdocs"} and $self->{"numuniq"} == $other->{"numuniq"}
!ll&&!rl&&r
302
$self->{"title"} eq $other->{"title"} and $self->{"num"} == $other->{"num"} and $self->{"stem"} == $other->{"stem"} and $self->{"stop"} == $other->{"stop"} and $self->{"numdocs"} == $other->{"numdocs"}
!ll&&!rl&&r
212
$self->{"title"} eq $other->{"title"} and $self->{"num"} == $other->{"num"} and $self->{"stem"} == $other->{"stem"} and $self->{"stop"} == $other->{"stop"}
!ll&&!rl&&r
113
$self->{"title"} eq $other->{"title"} and $self->{"num"} == $other->{"num"} and $self->{"stem"} == $other->{"stem"}
!ll&&!rl&&r
104
$self->{"title"} eq $other->{"title"} and $self->{"num"} == $other->{"num"}
!ll&&!rl&&r
014
MC/DC37%3/8
$self->{'title'} eq $other->{'title'} && $self->{'num'} == $other->{'num'} && $self->{'stem'} == $other->{'stem'} && $self->{'stop'} == $other->{'stop'} && $self->{'numdocs'} == $other->{'numdocs'} && $self->{'numuniq'} == $other->{'numuniq'} && $self->{'avgdoclen'} == $other->{'avgdoclen'} && $self->{'numterms'} == $other->{'numterms'}
$self->{"title"} eq $other->{"title"} $self->{"num"} == $other->{"num"} $self->{"stem"} == $other->{"stem"} $self->{"stop"} == $other->{"stop"} $self->{"numdocs"} == $other->{"numdocs"} $self->{"numuniq"} == $other->{"numuniq"} $self->{"avgdoclen"} == $other->{"avgdoclen"} $self->{'numterms'} == $other->{'numterms'}
Truth table44%4/9
A and B and C and D and E and F and G && H
A= $self->{"title"} eq $other->{"title"}B= $self->{"num"} == $other->{"num"}C= $self->{"stem"} == $other->{"stem"}D= $self->{"stop"} == $other->{"stop"}E= $self->{"numdocs"} == $other->{"numdocs"}F= $self->{"numuniq"} == $other->{"numuniq"}G= $self->{"avgdoclen"} == $other->{"avgdoclen"}H= $self->{'numterms'} == $other->{'numterms'}
ABCDEFGHresult
0XXXXXXX0
10XXXXXX0
110XXXXX0
1110XXXX0
11110XXX0
111110XX0
1111110X0
111111100
111111111
186 }
187  
188  
189  
190 =back
191  
192 =head1 AUTHOR
193  
194 Patrick Kaeding, C<< <pkaeding at cpan.org> >>
195  
196 =head1 BUGS
197  
198 Please report any bugs or feature requests to
199 C<bug-search-lemur at rt.cpan.org>, or through the web interface at
200 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Search-Lemur>.
201 I will be notified, and then you'll automatically be notified of progress on
202 your bug as I make changes.
203  
204 =head1 SUPPORT
205  
206 You can find documentation for this module with the perldoc command.
207  
208 perldoc Search::Lemur
209  
210 You can also look for information at:
211  
212 =over 4
213  
214 =item * AnnoCPAN: Annotated CPAN documentation
215  
216 L<http://annocpan.org/dist/Search-Lemur>
217  
218 =item * CPAN Ratings
219  
220 L<http://cpanratings.perl.org/d/Search-Lemur>
221  
222 =item * RT: CPAN's request tracker
223  
224 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Search-Lemur>
225  
226 =item * Search CPAN
227  
228 L<http://search.cpan.org/dist/Search-Lemur>
229  
230 =back
231  
232 =head1 ACKNOWLEDGEMENTS
233  
234 =head1 COPYRIGHT & LICENSE
235  
236 Copyright 2007 Patrick Kaeding, all rights reserved.
237  
238 This program is free software; you can redistribute it and/or modify it
239 under the same terms as Perl itself.
240  
241 =cut
242  
243 6 1;
↑ Summary Lemur.pm »