line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package KinoSearch1::Search::Weight; |
2
|
18
|
|
|
18
|
|
116
|
use strict; |
|
18
|
|
|
|
|
45
|
|
|
18
|
|
|
|
|
604
|
|
3
|
18
|
|
|
18
|
|
99
|
use warnings; |
|
18
|
|
|
|
|
41
|
|
|
18
|
|
|
|
|
415
|
|
4
|
18
|
|
|
18
|
|
97
|
use KinoSearch1::Util::ToolSet; |
|
18
|
|
|
|
|
35
|
|
|
18
|
|
|
|
|
2491
|
|
5
|
18
|
|
|
18
|
|
102
|
use base qw( KinoSearch1::Util::Class ); |
|
18
|
|
|
|
|
36
|
|
|
18
|
|
|
|
|
2281
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN { |
8
|
18
|
|
|
18
|
|
240
|
__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
|
|
|
0
|
0
|
0
|
sub get_query { shift->{parent} } |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Return the Weight's numerical value, now that it's been calculated. |
25
|
483
|
|
|
483
|
0
|
2467
|
sub get_value { shift->{value} } |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Return a damping/normalization factor for the Weight/Query. |
28
|
|
|
|
|
|
|
sub sum_of_squared_weights { |
29
|
559
|
|
|
559
|
0
|
880
|
my $self = shift; |
30
|
559
|
|
|
|
|
2244
|
$self->{query_weight} = $self->{idf} * $self->{parent}->get_boost; |
31
|
559
|
|
|
|
|
3557
|
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
|
|
|
|
|
|
|
sub normalize { |
38
|
559
|
|
|
559
|
0
|
910
|
my ( $self, $query_norm ) = @_; |
39
|
559
|
|
|
|
|
7119
|
$self->{query_norm} = $query_norm; |
40
|
559
|
|
|
|
|
897
|
$self->{query_weight} *= $query_norm; |
41
|
559
|
|
|
|
|
3250
|
$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
|
|
|
0
|
0
|
|
sub scorer { shift->abstract_death } |
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
|
|
|
0
|
0
|
|
sub explain { shift->todo_death } |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub to_string { |
67
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
68
|
0
|
|
|
|
|
|
return "weight(" . $self->{parent}->to_string . ")"; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |