| 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 | 6 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||
| 6 | package Search::Lemur::ResultItem; | ||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||
| 9 | =head1 NAME | ||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||
| 11 | Lemur::ResultItem | ||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||
| 13 | =head1 VERSION | ||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||
| 15 | Version 1.0 | ||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||
| 17 | =cut | ||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||
| 19 | 6 | our $VERSION = '1.00'; | |||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||
| 21 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||
| 24 | =cut | ||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||
| 26 | =head2 Main Methods | ||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||
| 28 | =over 2 | ||||||||||||||||||||||||||||||||||
| 29 | =cut | ||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||
| 31 | # create a new result object. This should only be called by a | ||||||||||||||||||||||||||||||||||
| 32 | # Lemur object, in its query method. One of these will be created | ||||||||||||||||||||||||||||||||||
| 33 | # for every result returned by the query. | ||||||||||||||||||||||||||||||||||
| 34 | # | ||||||||||||||||||||||||||||||||||
| 35 | # The arguments are query term, the document ID, document length, | ||||||||||||||||||||||||||||||||||
| 36 | # and term frequency. | ||||||||||||||||||||||||||||||||||
| 37 | # | ||||||||||||||||||||||||||||||||||
| 38 | # If these arguments are not given, this will die. | ||||||||||||||||||||||||||||||||||
| 39 | 12 | ▶ | sub _new { | ||||||||||||||||||||||||||||||||
|
Subroutine
_new: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||
| 40 | 12 | my $class = shift; | |||||||||||||||||||||||||||||||||
| 41 | 12 | my $self = {}; | |||||||||||||||||||||||||||||||||
| 42 | 12 | ▶ | if (scalar(@_) == 3) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 43 | 12 | my ($docid, $doclen, $tf) = @_; | |||||||||||||||||||||||||||||||||
| 44 | 12 | $self = { docid => $docid, | |||||||||||||||||||||||||||||||||
| 45 | doclen => $doclen, | ||||||||||||||||||||||||||||||||||
| 46 | tf => $tf }; | ||||||||||||||||||||||||||||||||||
| 47 | 0 | } else { die "Not enough arguments to create a resultItem object."; } | |||||||||||||||||||||||||||||||||
| 48 | 12 | bless $self, $class; | |||||||||||||||||||||||||||||||||
| 49 | 12 | return $self; | |||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||
| 52 | =item docid | ||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||
| 54 | Get the document ID value for this result. | ||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||
| 56 | =cut | ||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||
| 58 | 14 | ▶ | sub docid { | ||||||||||||||||||||||||||||||||
|
Subroutine
docid: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 59 | 14 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | if (@_) { $self->{url} = shift; } | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 61 | 14 | return $self->{docid}; | |||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||
| 64 | =item doclen | ||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||
| 66 | Get the document length for this result. | ||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||
| 68 | =cut | ||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||
| 70 | 16 | ▶ | sub doclen { | ||||||||||||||||||||||||||||||||
|
Subroutine
doclen: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 71 | 16 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | if (@_) { $self->{url} = shift; } | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 73 | 16 | return $self->{doclen}; | |||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||
| 77 | =item tf | ||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||
| 79 | Get the term frequency value for this result. | ||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||
| 81 | =cut | ||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||
| 83 | 18 | ▶ | sub tf { | ||||||||||||||||||||||||||||||||
|
Subroutine
tf: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 84 | 18 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | if (@_) { $self->{url} = shift; } | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 86 | 18 | return $self->{tf}; | |||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||
| 89 | =item equals | ||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||
| 91 | Test equality between this resultItem and the given one (used mostly for | ||||||||||||||||||||||||||||||||||
| 92 | testing). | ||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||
| 94 | =cut | ||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||
| 96 | 9 | ▶ | sub equals { | ||||||||||||||||||||||||||||||||
|
Subroutine
equals: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 97 | 9 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 98 | 9 | my $other = shift; | |||||||||||||||||||||||||||||||||
| 99 | 9 | ▶ | return 0 unless ($other->isa('Search::Lemur::ResultItem')); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 100 | 8 | ▶ | return ($self->tf() == $other->tf()) && | ||||||||||||||||||||||||||||||||
|
Condition100%6/6
$self->tf == $other->tf && $self->doclen == $other->doclen && $self->docid == $other->docid
$self->tf == $other->tf and $self->doclen == $other->doclen
MC/DC100%3/3
$self->tf == $other->tf && $self->doclen == $other->doclen && $self->docid == $other->docid
$self->tf == $other->tf
$self->doclen == $other->doclen
$self->docid == $other->docid
Truth table100%4/4
A and B && C
A= $self->tf == $other->tfB= $self->doclen == $other->doclenC= $self->docid == $other->docid
| |||||||||||||||||||||||||||||||||||
| 101 | ($self->doclen() == $other->doclen()) && | ||||||||||||||||||||||||||||||||||
| 102 | ($self->docid() == $other->docid()); | ||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||
| 105 | =back | ||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||
| 107 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||
| 109 | Patrick Kaeding, C<< <pkaeding at cpan.org> >> | ||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||
| 111 | =head1 BUGS | ||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||
| 113 | Please report any bugs or feature requests to | ||||||||||||||||||||||||||||||||||
| 114 | C<bug-search-lemur at rt.cpan.org>, or through the web interface at | ||||||||||||||||||||||||||||||||||
| 115 | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Search-Lemur>. | ||||||||||||||||||||||||||||||||||
| 116 | I will be notified, and then you'll automatically be notified of progress on | ||||||||||||||||||||||||||||||||||
| 117 | your bug as I make changes. | ||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||
| 119 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||
| 121 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||
| 123 | perldoc Search::Lemur | ||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||
| 125 | You can also look for information at: | ||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||
| 127 | =over 4 | ||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||
| 129 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||
| 131 | L<http://annocpan.org/dist/Search-Lemur> | ||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||
| 133 | =item * CPAN Ratings | ||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||
| 135 | L<http://cpanratings.perl.org/d/Search-Lemur> | ||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||
| 137 | =item * RT: CPAN's request tracker | ||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||
| 139 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Search-Lemur> | ||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||
| 141 | =item * Search CPAN | ||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||
| 143 | L<http://search.cpan.org/dist/Search-Lemur> | ||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||
| 145 | =back | ||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||
| 147 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||
| 149 | =head1 COPYRIGHT & LICENSE | ||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||
| 151 | Copyright 2007 Patrick Kaeding, all rights reserved. | ||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||
| 153 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||
| 154 | under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||
| 156 | =cut | ||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||
| 158 | 6 | 1; | |||||||||||||||||||||||||||||||||