my ($record, $id) = @_;
my %marc = (); $marc{isbns} = [];
+ # reset misc score
+ $conf->{misc_score} = 999;
+
# id, stringified
$marc{id} = $id->as_string($conf->{subfield});
Assign a score to the record based on various criteria.
-Score is constructed by pushing elements onto a list. At the end of
-the routine, the list is flattened into a string via join();
+Score is constructed by pushing elements onto a list, via a dispatch
+table. This allows order of fingerprints in the output file to be
+varied.
=cut
push @score, $scores_code{$_}->($marc, $record);
$json .= $_ . ':' . $score[-1] . ',';
}
- chop($json); # get rid of the trailing comma
+ # add misc score
+ $json .= 'misc:' . $conf->{misc_score};
$json .= '}';
- my $compact = join('', @score);
+ my $compact = join('', @score, $conf->{misc_score});
$marc->{score} = "$compact\t$json";
}
binmode(STDIN, ':utf8');
my $rc = GetOptions( $c,
- 'incoming',
- 'incumbent',
'exception|x=s',
- 'marctype|m=s',
'output|o=s',
- 'runtype|r=s',
+ 'prefix|p=s',
+ 'marctype|m=s',
'subfield|s=s',
'tag|t=s',
'fingerprints=s',
$c->{dyn_scores} = [ qw/oclc dlc num_650 num_tags enc_lvl/ ];
}
- # set defaults if told to do so
- if ($c->{incoming}) {
- $c->{tag} = 903 unless defined $c->{tag};
- $c->{subfield} = 'a' unless defined $c->{subfield};
- $c->{marctype} = 'XML' unless defined $c->{marctype};
- $c->{output} = 'incoming.fp' unless defined $c->{output};
- $c->{exception} = 'incoming.ex' unless defined $c->{exception};
- } elsif ($c->{incumbent}) {
- $c->{tag} = 901 unless defined $c->{tag};
- $c->{subfield} = 'c' unless defined $c->{subfield};
- $c->{marctype} = 'XML' unless defined $c->{marctype};
- $c->{output} = 'incumbent.fp' unless defined $c->{output};
- $c->{exception} = 'incumbent.ex' unless defined $c->{exception};
+ # set defaults
+ $c->{tag} = 903 unless defined $c->{tag};
+ $c->{subfield} = 'a' unless defined $c->{subfield};
+ $c->{marctype} = 'XML' unless defined $c->{marctype};
+ if ($c->{prefix}) {
+ $c->{output} = join('.',$c->{prefix},'fp');
+ $c->{exception} = join('.',$c->{prefix},'fp','ex');
}
my @keys = keys %{$c};
print <<HELP;
Usage is: $0 [REQUIRED ARGS] [OPTIONS] <filelist>
Req'd Arguments
- --tag=N -t Which tag to use
- --subfield=X -s Which subfield to use
- --output=<file> -o Output filename
- --exceptions=<file> -x Exception report filename
+ --output=<FILE> -o Output filename
+ --exceptions=<FILE> -x Exception report filename
+ or
+ --prefix=<PREFIX>> -p Shared prefix for output/exception files. Will
+ produce PREFIX.fp and PREFIX.fp.ex
Options
- --incoming '-t 903 -s a -o incoming.fp -x incoming.ex'
- --incumbent '-t 901 -s c -o incumbent.fp -x incumbent.ex'
+ --tag=N -t Which tag to use (default 903)
+ --subfield=X -s Which subfield to use (default 'a')
+ --quiet -q Don't write status messages to STDOUT
--fingerprints=LIST Fingerprints to generate, comma separated
Default: oclc,isbn,edition,issn,lccn,accomp,authpub
Others: baseline
+
--scores=LIST Scores to calculate, comma separated
Default: oclc,dlc,num_650,num_tags,enc_level
- --quiet -q Don't write status messages to STDOUT
+
+ --marctype=TYPE Defaults to 'XML'
HELP
exit 1;
}