line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::JA::Summarize::Extract::Plugin::Scoring::Base; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
41
|
|
4
|
1
|
|
|
1
|
|
6
|
use base qw( Lingua::JA::Summarize::Extract::Plugin ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
448
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub scoring { |
7
|
0
|
|
|
0
|
0
|
|
my($self, $term_list) = @_; |
8
|
|
|
|
|
|
|
|
9
|
0
|
|
|
|
|
|
my $part_info = {}; |
10
|
0
|
|
|
|
|
|
for my $term (keys %{ $term_list }) { |
|
0
|
|
|
|
|
|
|
11
|
0
|
|
|
|
|
|
my @words = split /\s/, $term; |
12
|
0
|
0
|
|
|
|
|
next if @words < 2; |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
for my $i (0 .. $#words - 1) { |
15
|
0
|
|
|
|
|
|
$part_info->{$words[$i]}->{pre}++; |
16
|
0
|
|
|
|
|
|
$part_info->{$words[$i + 1]}->{post}++; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my $ret_list = {}; |
21
|
0
|
|
|
|
|
|
for my $term (keys %{ $term_list }) { |
|
0
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
my $score = 1; |
23
|
0
|
|
|
|
|
|
my @words = split /\s/, $term; |
24
|
0
|
|
|
|
|
|
for my $word (@words){ |
25
|
0
|
|
|
|
|
|
for my $key (qw/ pre post /) { |
26
|
0
|
|
0
|
|
|
|
$score *= ($part_info->{$word}->{$key} || 0) + 1; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
0
|
|
|
|
$score = $score ** (1 / (2 * $self->rate * (scalar @words || 1))); |
31
|
0
|
|
|
|
|
|
$score *= $term_list->{$term}; |
32
|
0
|
|
|
|
|
|
$ret_list->{$term} = $score; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
$self->scoring_fixup($ret_list); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub scoring_fixup { |
39
|
0
|
|
|
0
|
0
|
|
my($self, $scoring) = @_; |
40
|
0
|
|
|
|
|
|
my @fixdata = map { |
41
|
0
|
|
|
|
|
|
+{ |
42
|
|
|
|
|
|
|
term => $_, |
43
|
|
|
|
|
|
|
score => $scoring->{$_}, |
44
|
|
|
|
|
|
|
} |
45
|
0
|
|
|
|
|
|
} sort { $scoring->{$b} <=> $scoring->{$a} } keys %{ $scoring }; |
|
0
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
return \@fixdata; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |