line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MARC::Record::Stats::Report; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
69
|
|
4
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
927
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
MARC::Record::Stats::Report - report generator for MARC::Record::Stats |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
See SYNOPSIS and report method in L |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 METHODS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head2 report $fh, $stats, $config? |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Prints out to a filehandle $fh a report on statistics |
19
|
|
|
|
|
|
|
collected in $stats (L), |
20
|
|
|
|
|
|
|
using options from $config, which is a HASHREF with keys: |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=over |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=item dots => [undef|0|1] |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Replace spaces with dots if dots => 1 for readability. Table will look like: |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
955..............86.67 |
29
|
|
|
|
|
|
|
...a.............86.67 |
30
|
|
|
|
|
|
|
...e.............20.00 |
31
|
|
|
|
|
|
|
...t.............46.67 |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=back |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub report{ |
38
|
0
|
|
|
0
|
1
|
|
my ($self, $FH, $stats, $config) = @_; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my $hash = $stats->get_stats_hash; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my @lines; |
43
|
0
|
|
|
|
|
|
my $nrecords = $hash->{nrecords}; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
foreach my $tag ( sort keys %{$hash->{tags}} ) { |
|
0
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $tagstat = $hash->{tags}->{$tag}; |
47
|
0
|
0
|
|
|
|
|
my $is_repeatable = $tagstat->{repeatable} ? '[Y]' : ' '; |
48
|
0
|
|
|
|
|
|
my $occurence = sprintf("%6.2f",100*$tagstat->{occurence}/$nrecords); |
49
|
0
|
|
|
|
|
|
push @lines, "$tag $is_repeatable $occurence"; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
foreach my $subtag ( sort keys %{ $tagstat->{subtags} } ) { |
|
0
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my $subtagstat = $tagstat->{subtags}->{$subtag}; |
53
|
0
|
|
|
|
|
|
my $occurence = sprintf("%6.2f",100.0*$subtagstat->{occurence}/$nrecords); |
54
|
0
|
0
|
|
|
|
|
my $is_repeatable = $tagstat->{repeatable} ? '[Y]' : ' '; |
55
|
0
|
|
|
|
|
|
push @lines, " $subtag $is_repeatable $occurence"; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
|
if ( $config->{'dots'} ) { |
61
|
0
|
|
|
|
|
|
@lines = map { s/\s/./g; $_ } @lines; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
unshift @lines, "Tag Rep. Occ.,%"; |
65
|
0
|
|
|
|
|
|
unshift @lines, "Statistics for $nrecords records"; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
print $FH join ("\n",@lines), qq{\n\n}; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 AUTHOR |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Andrei V. Toutoukine, C<< >> |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 BUGS |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
81
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
82
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 SUPPORT |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
perldoc MARC::Record::Stats::Report |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
You can also look for information at: |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=over 4 |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
L |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
L |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item * CPAN Ratings |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
L |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item * Search CPAN |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
L |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=back |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Copyright 2011 Andrei V. Toutoukine. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
125
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
126
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=cut |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
1; # End of MARC::Record::Stats::Report |