Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curation: fix rules; fix curator evaluation #1091

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions site/zenodo_rdm/curation/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@

CURATION_HIGH_CONF_KEYWORDS_EU = []
"""High confidence keywords for EU records."""

CURATION_TEST_PHRASES = []
"""Test record phrases."""
2 changes: 1 addition & 1 deletion site/zenodo_rdm/curation/curators.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _evaluator(self, results):
rule_score = current_curation.scores.get(rule)
if result is None:
continue
elif isinstance(rule_score, int):
elif type(rule_score) is int:
score += rule_score if result else 0
elif isinstance(rule_score, bool):
if result:
Expand Down
12 changes: 7 additions & 5 deletions site/zenodo_rdm/curation/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ def award_acronym_in_title(record):
"""Check if EU award name in record title."""
award_service = current_service_registry.get("awards")
title = record.metadata["title"]
funding = record.metadata["funding"]

funding = record.metadata.get("funding", [])
for f in funding:
if f["funder"]["id"] == "00k4n6c32":
if f["funder"].get("id") == "00k4n6c32":
if award_id := f.get("award", {}).get("id"):
award = award_service.record_cls.pid.resolve(award_id)
if award.get("acronym") and (
Expand All @@ -64,12 +64,14 @@ def published_before_award_start(record):
"""Check if published before award start date."""
award_service = current_service_registry.get("awards")

for f in record.metadata["funding"]:
if f["funder"]["id"] == "00k4n6c32":
funding = record.metadata.get("funding", [])
for f in funding:
if f["funder"].get("id") == "00k4n6c32":
if award_id := f.get("award", {}).get("id"):
award = award_service.record_cls.pid.resolve(award_id)
if award.get("start_date") and (
record.created < arrow.get(award.get("start_date")).datetime
record.created.timestamp()
< arrow.get(award.get("start_date")).datetime.timestamp()
):
return True
return False
Expand Down