line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package KinoSearch1::Document::Doc; |
2
|
34
|
|
|
34
|
|
238
|
use strict; |
|
34
|
|
|
|
|
70
|
|
|
34
|
|
|
|
|
1777
|
|
3
|
34
|
|
|
34
|
|
195
|
use warnings; |
|
34
|
|
|
|
|
1140
|
|
|
34
|
|
|
|
|
1174
|
|
4
|
34
|
|
|
34
|
|
194
|
use KinoSearch1::Util::ToolSet; |
|
34
|
|
|
|
|
82
|
|
|
34
|
|
|
|
|
11962
|
|
5
|
34
|
|
|
34
|
|
222
|
use base qw( KinoSearch1::Util::Class ); |
|
34
|
|
|
|
|
71
|
|
|
34
|
|
|
|
|
3981
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN { |
8
|
34
|
|
|
34
|
|
474
|
__PACKAGE__->init_instance_vars( |
9
|
|
|
|
|
|
|
# special member - used to keep track of boost |
10
|
|
|
|
|
|
|
_kino_boost => 1, |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub set_value { |
15
|
15358
|
|
|
15358
|
1
|
54720
|
my ( $self, $field_name, $value ) = @_; |
16
|
15358
|
50
|
|
|
|
29497
|
carp("undef supplied to set_value") unless defined $value; |
17
|
15358
|
|
|
|
|
47428
|
$self->{$field_name}->set_value($value); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub get_value { |
21
|
3
|
|
|
3
|
1
|
15
|
return $_[0]->{ $_[1] }->get_value; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
4
|
|
|
4
|
0
|
14
|
sub get_field { $_[0]->{ $_[1] } } |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub boost_field { |
27
|
1
|
|
|
1
|
0
|
15
|
$_[0]->{ $_[1] }->set_boost( $_[2] ); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
1
|
1
|
10
|
sub set_boost { $_[0]->{_kino_boost} = $_[1] } |
31
|
14017
|
|
|
14017
|
1
|
32456
|
sub get_boost { $_[0]->{_kino_boost} } |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# set the analyzer for a field |
34
|
|
|
|
|
|
|
sub set_analyzer { |
35
|
0
|
|
|
0
|
0
|
0
|
$_[0]->{ $_[1] }->set_analyzer( $_[2] ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub add_field { |
39
|
254
|
|
|
254
|
0
|
430
|
my ( $self, $field ) = @_; |
40
|
254
|
50
|
|
|
|
1014
|
croak("argument to add_field must be a KinoSearch1::Document::Field") |
41
|
|
|
|
|
|
|
unless $field->isa('KinoSearch1::Document::Field'); |
42
|
254
|
|
|
|
|
1035
|
$self->{ $field->get_name } = $field; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# retrieve all fields |
46
|
|
|
|
|
|
|
sub get_fields { |
47
|
42114
|
|
|
42114
|
0
|
47682
|
return grep {ref} values %{ $_[0] }; |
|
88415
|
|
|
|
|
215981
|
|
|
42114
|
|
|
|
|
97636
|
|
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Return the doc as a hashref, with the field names as hash keys and the |
51
|
|
|
|
|
|
|
# field # values as values. |
52
|
|
|
|
|
|
|
sub to_hashref { |
53
|
46
|
|
|
46
|
0
|
76
|
my $self = shift; |
54
|
46
|
|
|
|
|
72
|
my %hash; |
55
|
46
|
|
|
|
|
149
|
$hash{ $_->get_name } = $_->get_value for grep {ref} values %$self; |
|
166
|
|
|
|
|
706
|
|
56
|
46
|
|
|
|
|
180
|
return \%hash; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |