| 1 | package KinoSearch1::Search::Weight; | ||
| 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 | # constructor args / members | ||
| 10 | parent => undef, | ||
| 11 | searcher => undef, | ||
| 12 | # members | ||
| 13 | similarity => undef, | ||
| 14 | value => 0, | ||
| 15 | idf => undef, | ||
| 16 | query_norm => undef, | ||
| 17 | query_weight => undef, | ||
| 18 | ); | ||
| 19 | } | ||
| 20 | |||
| 21 | # Return the Query that the Weight was derived from. | ||
| 22 | 0 | ▶ | sub get_query { shift->{parent} } |
|
Subroutine
get_query: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 23 | |||
| 24 | # Return the Weight's numerical value, now that it's been calculated. | ||
| 25 | 476 | ▶ | sub get_value { shift->{value} } |
|
Subroutine
get_value: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 26 | |||
| 27 | # Return a damping/normalization factor for the Weight/Query. | ||
| 28 | 551 | ▶ | sub sum_of_squared_weights { |
|
Subroutine
sum_of_squared_weights: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 29 | 551 | my $self = shift; | |
| 30 | 551 | $self->{query_weight} = $self->{idf} * $self->{parent}->get_boost; | |
| 31 | 551 | return ( $self->{query_weight}**2 ); | |
| 32 | } | ||
| 33 | |||
| 34 | # Normalize the Weight/Query, so that it produces more comparable numbers in | ||
| 35 | # context of other Weights/Queries. | ||
| 36 | |||
| 37 | 551 | ▶ | sub normalize { |
|
Subroutine
normalize: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 38 | 551 | my ( $self, $query_norm ) = @_; | |
| 39 | 551 | $self->{query_norm} = $query_norm; | |
| 40 | 551 | $self->{query_weight} *= $query_norm; | |
| 41 | 551 | $self->{value} = $self->{query_weight} * $self->{idf}; | |
| 42 | } | ||
| 43 | |||
| 44 | =begin comment | ||
| 45 | |||
| 46 | my $scorer = $weight->scorer( $index_reader ); | ||
| 47 | |||
| 48 | Return a subclass of scorer, primed with values and ready to crunch numbers. | ||
| 49 | |||
| 50 | =end comment | ||
| 51 | =cut | ||
| 52 | |||
| 53 | 0 | ▶ | sub scorer { shift->abstract_death } |
|
Subroutine
scorer: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 54 | |||
| 55 | =begin comment | ||
| 56 | |||
| 57 | my $explanation = $weight->explain( $index_reader, $doc_num ); | ||
| 58 | |||
| 59 | Explain how a document scores. | ||
| 60 | |||
| 61 | =end comment | ||
| 62 | =cut | ||
| 63 | |||
| 64 | 0 | ▶ | sub explain { shift->todo_death } |
|
Subroutine
explain: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 65 | |||
| 66 | 0 | ▶ | sub to_string { |
|
Subroutine
to_string: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 67 | 0 | my $self = shift; | |
| 68 | 0 | return "weight(" . $self->{parent}->to_string . ")"; | |
| 69 | } | ||
| 70 | |||
| 71 | 18 | 1; | |
| 72 | |||
| 73 | __END__ | ||