Skip to content

Commit

Permalink
TTO-184 Rights predictor to 75 for Canada anonymous works
Browse files Browse the repository at this point in the history
- Rights predictor for Canada is now sensitive to the is_pub/anonymous/corporate status of a work
  - Use a new constant CANADA_CORPORATE_TERM set to 75 years
  - Pass the is_pub flag to all per-country rights predictors
  - Update tests with a separate author death date vs anonymous/pub date example for Canada
  • Loading branch information
moseshll committed Mar 6, 2024
1 parent fd7f9ca commit ebaafdc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
19 changes: 13 additions & 6 deletions lib/CRMS/RightsPredictor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ use constant {
# Thus, if last source copyright year >= 1996 then the work is GATT-eligible.
GATT_RESTORATION_START => 1996,
COMMONWEALTH_CROWN_COPYRIGHT_TERM => 50,
COMMONWEALTH_STANDARD_TERM => 70
COMMONWEALTH_STANDARD_TERM => 70,
CANADA_CORPORATE_TERM => 75
};

# Sanity check on reviewer-supplied date
Expand Down Expand Up @@ -69,11 +70,13 @@ sub new {
sub last_source_copyright {
my $self = shift;
my $death_or_pub_date = shift || ''; # Reviewer-supplied
my $is_pub = shift;
my $is_crown = shift; # Crown copyright
my $reference_year = shift || POSIX::strftime("%Y", localtime); # The "current" year

# Initialize return struct
my $prediction = { death_or_pub_date => $death_or_pub_date,
is_pub => $is_pub,
is_crown => $is_crown,
reference_year => $reference_year,
desc => [],
Expand Down Expand Up @@ -204,30 +207,34 @@ sub predict_last_source_copyright {
return if $prediction->{error};
my $country = $self->{record}->country;
my $predictor = $TERM_PREDICTORS->{$country};
my $term = $predictor->($prediction->{death_or_pub_date}, $prediction->{is_crown});
my $term = $predictor->(
$prediction->{death_or_pub_date},
$prediction->{is_pub},
$prediction->{is_crown}
);
$prediction->{last_source_copyright_year} = $prediction->{death_or_pub_date} + $term;
push @{$prediction->{desc}},
"Last $country © $prediction->{last_source_copyright_year} ($prediction->{death_or_pub_date} + $term-year term)";
}

sub australia_term {
my ($death_or_pub_date, $is_crown) = @_;
my ($death_or_pub_date, $is_pub, $is_crown) = @_;

return COMMONWEALTH_CROWN_COPYRIGHT_TERM if $is_crown;
return 50 if $death_or_pub_date < 1955;
return COMMONWEALTH_STANDARD_TERM;
}

sub canada_term {
my ($death_or_pub_date, $is_crown) = @_;
my ($death_or_pub_date, $is_pub, $is_crown) = @_;

return COMMONWEALTH_CROWN_COPYRIGHT_TERM if $is_crown;
return 50 if $death_or_pub_date < 1972;
return COMMONWEALTH_STANDARD_TERM;
return $is_pub ? CANADA_CORPORATE_TERM : COMMONWEALTH_STANDARD_TERM;
}

sub united_kingdom_term {
my ($death_or_pub_date, $is_crown) = @_;
my ($death_or_pub_date, $is_pub, $is_crown) = @_;

return ($is_crown) ? COMMONWEALTH_CROWN_COPYRIGHT_TERM : COMMONWEALTH_STANDARD_TERM;
}
Expand Down
16 changes: 12 additions & 4 deletions t/lib/CRMS/RightsPredictor.t
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ subtest 'RightsPredictor::last_source_copyright' => sub {
my $f008 = '850423s1940 uk a 000 0 eng d';
my $record = FakeMetadata::fake_record_with_008_and_leader($f008);
my $rp = CRMS::RightsPredictor->new(record => $record);
my $res = $rp->last_source_copyright(2000, 1);
my $res = $rp->last_source_copyright(2000, 0, 1);
is($res->{last_source_copyright_year}, 2050);
};

Expand All @@ -51,19 +51,27 @@ subtest 'RightsPredictor::last_source_copyright' => sub {
is($res->{last_source_copyright_year}, 2042);
};

subtest 'Canada post-1972' => sub {
subtest 'Canada post-1972 author death date' => sub {
my $f008 = '850423s1940 cn a 000 0 eng d';
my $record = FakeMetadata::fake_record_with_008_and_leader($f008);
my $rp = CRMS::RightsPredictor->new(record => $record);
my $res = $rp->last_source_copyright(2000);
is($res->{last_source_copyright_year}, 2070);
};

subtest 'Canada crown' => sub {
subtest 'Canada post-1972 corporate work' => sub {
my $f008 = '850423s1940 cn a 000 0 eng d';
my $record = FakeMetadata::fake_record_with_008_and_leader($f008);
my $rp = CRMS::RightsPredictor->new(record => $record);
my $res = $rp->last_source_copyright(2000, 1);
is($res->{last_source_copyright_year}, 2075);
};

subtest 'Canada crown' => sub {
my $f008 = '850423s1940 cn a 000 0 eng d';
my $record = FakeMetadata::fake_record_with_008_and_leader($f008);
my $rp = CRMS::RightsPredictor->new(record => $record);
my $res = $rp->last_source_copyright(2000, 0, 1);
is($res->{last_source_copyright_year}, 2050);
};

Expand Down Expand Up @@ -95,7 +103,7 @@ subtest 'RightsPredictor::last_source_copyright' => sub {
my $f008 = '850423s1940 at a 000 0 eng d';
my $record = FakeMetadata::fake_record_with_008_and_leader($f008);
my $rp = CRMS::RightsPredictor->new(record => $record);
my $res = $rp->last_source_copyright(2000, 1);
my $res = $rp->last_source_copyright(2000, 0, 1);
is($res->{last_source_copyright_year}, 2050);
};

Expand Down

0 comments on commit ebaafdc

Please sign in to comment.