| 1 | package KinoSearch1::Search::Searchable; | ||||||||||||||||||||||||||||
| 2 | 18 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 18 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 18 | ▶ | use KinoSearch1::Util::ToolSet; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 18 | ▶ | use base qw( KinoSearch1::Util::Class ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 18 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 18 | __PACKAGE__->init_instance_vars( | |||||||||||||||||||||||||||
| 9 | # members | ||||||||||||||||||||||||||||
| 10 | similarity => undef, | ||||||||||||||||||||||||||||
| 11 | field_sims => undef, # {} | ||||||||||||||||||||||||||||
| 12 | ); | ||||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 18 | ▶ | use KinoSearch1::Search::Similarity; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | =begin comment | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | my $hits = $searchable->search($query_string); | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | my $hits = $searchable->search( | ||||||||||||||||||||||||||||
| 22 | query => $query, | ||||||||||||||||||||||||||||
| 23 | filter => $filter, | ||||||||||||||||||||||||||||
| 24 | sort_spec => $sort_spec, | ||||||||||||||||||||||||||||
| 25 | ); | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | =end comment | ||||||||||||||||||||||||||||
| 28 | =cut | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | sub search { shift->abstract_death } | ||||||||||||||||||||||||||
|
Subroutine
search: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | =begin comment | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | my $explanation = $searchable->explain( $weight, $doc_num ); | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | Provide an Explanation for how the document represented by $doc_num scored | ||||||||||||||||||||||||||||
| 37 | agains $weight. Useful for probing the guts of Similarity. | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | =end comment | ||||||||||||||||||||||||||||
| 40 | =cut | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub explain { shift->todo_death } | ||||||||||||||||||||||||||
|
Subroutine
explain: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | =begin comment | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | my $doc_num = $searchable->max_doc; | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | Return one larger than the largest doc_num. | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | =end comment | ||||||||||||||||||||||||||||
| 51 | =cut | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | ▶ | sub max_doc { shift->abstract_death } | ||||||||||||||||||||||||||
|
Subroutine
max_doc: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | =begin comment | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | my $doc = $searchable->fetch_doc($doc_num); | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | Generate a Doc object, retrieving the stored fields from the invindex. | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =end comment | ||||||||||||||||||||||||||||
| 62 | =cut | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 0 | ▶ | sub fetch_doc { shift->abstract_death } | ||||||||||||||||||||||||||
|
Subroutine
fetch_doc: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | =begin comment | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | my $doc_freq = $searchable->doc_freq($term); | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | Return the number of documents which contain this Term. Used for calculating | ||||||||||||||||||||||||||||
| 71 | Weights. | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | =end comment | ||||||||||||||||||||||||||||
| 74 | =cut | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | ▶ | sub doc_freq { shift->abstract_death } | ||||||||||||||||||||||||||
|
Subroutine
doc_freq: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | =begin comment | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | $searchable->set_similarity($sim); | ||||||||||||||||||||||||||||
| 81 | $searchable->set_similarity( $field_name, $alternate_sim ); | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | my $sim = $searchable->get_similarity; | ||||||||||||||||||||||||||||
| 84 | my $alt_sim = $searchable->get_similarity($field_name); | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | Set or get Similarity. If a field name is included, set/retrieve the | ||||||||||||||||||||||||||||
| 87 | Similarity instance for that field only. | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | =end comment | ||||||||||||||||||||||||||||
| 90 | =cut | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 1 | ▶ | sub set_similarity { | ||||||||||||||||||||||||||
|
Subroutine
set_similarity: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 93 | 1 | ▶ | if ( @_ == 3 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | 1 | my ( $self, $field_name, $sim ) = @_; | |||||||||||||||||||||||||||
| 95 | 1 | $self->{field_sims}{$field_name} = $sim; | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | else { | ||||||||||||||||||||||||||||
| 98 | 0 | $_[0]->{similarity} = $_[1]; | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 1084 | ▶ | sub get_similarity { | ||||||||||||||||||||||||||
|
Subroutine
get_similarity: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 103 | 1084 | my ( $self, $field_name ) = @_; | |||||||||||||||||||||||||||
| 104 | 1084 | ▶ | if ( defined $field_name and exists $self->{field_sims}{$field_name} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $field_name and exists $self->{"field_sims"}{$field_name}
MC/DC100%2/2
defined $field_name and exists $self->{"field_sims"}{$field_name}
defined $field_name
exists $self->{"field_sims"}{$field_name}
Truth table100%3/3
A and B
A= defined $field_nameB= exists $self->{"field_sims"}{$field_name}
| |||||||||||||||||||||||||||||
| 105 | 1 | return $self->{field_sims}{$field_name}; | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | else { | ||||||||||||||||||||||||||||
| 108 | 1083 | return $self->{similarity}; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | # not sure these are needed (call $query->create_weight($searcher) instead) | ||||||||||||||||||||||||||||
| 113 | 0 | ▶ | sub create_weight { shift->unimplemented_death } | ||||||||||||||||||||||||||
|
Subroutine
create_weight: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 114 | 0 | ▶ | sub rewrite_query { shift->unimplemented_death } | ||||||||||||||||||||||||||
|
Subroutine
rewrite_query: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 7 | ▶ | sub doc_freqs { | ||||||||||||||||||||||||||
|
Subroutine
doc_freqs: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 117 | 7 | my ( $self, $terms ) = @_; | |||||||||||||||||||||||||||
| 118 | 7 | my @doc_freqs = map { $self->doc_freq($_) } @$terms; | |||||||||||||||||||||||||||
| 119 | 7 | return \@doc_freqs; | |||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 0 | ▶ | sub close { } | ||||||||||||||||||||||||||
|
Subroutine
close: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 18 | 1; | |||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | __END__ | ||||||||||||||||||||||||||||