NAME
MARC::Record::Stats - scans one or many MARC::Record and gives a statistics on the tags and subtags
VERSION
Version 0.0.4
SYNOPSIS
This module provides functionality for marcstats.pl script. Description of the module interface follows.
use MARC::Record::Stats;
{
my $records = [];
# code skipped ...
my $stats = MARC::Record::Stats->new;
# $records is array of MARC::Record
for my $r ( @$records ) {
$stats->add_record_to_stats( $r );
}
$stats->report( *STDOUT, { dots => 1 } );
}
###
### Some useless features:
###
{
my $record;
my $records = [];
# code skipped ...
# single record statistics
# $record is a MARC::Record
my $stats1 = Marc::Record::Stats->new( $record );
# merge $stats1 and statistics for $records
# $records is a reference to an array of MARC::Record
my $stats2 = Marc::Record::Stats->new( $records, $stats1 );
# ...
$stats1->report( *STDOUT );
# $stats2->report( *STDOUT );
}
METHODS
new $records [, $stats]
Builds statistics on $records, appends $stats if given.
- $records A MARC::Record or a reference to an array of MARC::Record
- $stats Marc::Record::Stats object that contains accumulated statistics.
report $fh, $config
Prints out a report on the collected statistics to a filehandle $fh. $config keeps configuretion for the reporter. See MARC::Record::Stats::Report for details
get_stats_hash
Returns a hashref that contains the statistics:
<stats_hash> = {
nrecords => <int>, # the number of records
tags => {
<tag> => <tagstat>, # for every tag found in records
...
}
}
<tag> = \d{3} # a tag, three digits
<tag_stat> = {
occurence => <int>, # how many records contain this tag
subtags => <subtag_stat>,
}
<subtag_stat> = {
<subtag> => {
occurence => <int>, # how many records contain this subtag
repeatable => <0|1>, # whether or not is repeatable
}
}
<subtag> = [a-z0-9] # alphanum, subtag
add_record_to_stats $record
Add $record to statistics.
get_record_stats $record
returns a reference to a hash: { <tag> => <tag_data> } where <tag_data> is a reference to a hash with the keys occurence - how many times the field with the tag <tag> was found in the record, subtags - result of subtag_stats.
subtag_stats $field
returns a reference to a hash { <subtag letter> => <occurence> } where <occurence> is the number of times the subfield with the code <subtag letter> was found in the fied $field.
$field is MARC::Field
AUTHOR
Andrei V. Toutoukine, <tut at isuct.ru>
BUGS
Please report any bugs or feature requests to bug-marc-record-stats at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Marc-Record-Stats. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Marc::Record::Stats
You can also look for information at:
RT: CPAN's request tracker
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
Copyright 2011 Andrei V. Toutoukine.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.