Skip to content

Commit

Permalink
Use new RightsPredictor interface in PDD script.
Browse files Browse the repository at this point in the history
  • Loading branch information
moseshll committed Feb 20, 2024
1 parent 7e9d409 commit e334bdb
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions bin/newyear.pl
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,20 @@ sub ProcessCommonwealthProject {
my $date = $data->{'date'};
my $pub = $data->{'pub'};
my $crown = $data->{'crown'};
my $actual = $data->{'actual'};
my $dates = [];
push @$dates, [$date, $pub] if defined $date;
my @matches = $note =~ /(?<!\d)1\d\d\d(?![\d\-])/g;
foreach my $match (@matches) {
push @$dates, [$match, 0] if length $match and $match < $year;
}
foreach my $date (@$dates) {
my $prediction = $rp->rights($date->[0], $date->[1], $crown, $year);
if (defined $prediction->{rights}) {
$predictions{$prediction->{rights}} = 1;
my $rp = CRMS::RightsPredictor->new(record => $record, effective_date => $date->[0],
is_corporate => $date->[1], is_crown => $crown, pub_date => $actual,
reference_year => $year);
my $prediction = $rp->rights;
if (defined $prediction) {
$predictions{$prediction} = 1;
}
}
$alldates{$_->[0]} = 1 for @$dates;
Expand Down Expand Up @@ -317,7 +321,6 @@ sub ProcessCrownCopyrightProject {
next if $acurr eq 'pd' or $acurr =~ m/^cc/;
my $record = $crms->GetMetadata($id);
next unless defined $record;
my $rp = CRMS::RightsPredictor->new(record => $record);
my $gid = $row->[1];
my $time = $row->[2];
$seen{$id} = 1;
Expand All @@ -338,9 +341,14 @@ sub ProcessCrownCopyrightProject {
$date =~ s/^\s+|\s+$//g;
$dates{$date} = $date if defined $date;
foreach my $date (keys %dates) {
my $prediction = $rp->rights($date, 1, 1, $year);
if (defined $prediction->{rights}) {
$predictions{$prediction->{rights}} = 1;
# Crown Copyright project never collected author death dates, so there
# was no need to resort to an "actual pub date" field, thus no need to
# override the record pub date used by the predictor.
my $rp = CRMS::RightsPredictor->new(record => $record, effective_date => $date,
is_corporate => 1, is_crown => 1, reference_year => $year);
my $prediction = $rp->rights;
if (defined $prediction) {
$predictions{$prediction} = 1;
}
}
$alldates{$_} = 1 for keys %dates;
Expand Down

0 comments on commit e334bdb

Please sign in to comment.