Skip to content

Commit

Permalink
curation: add community name acronym check
Browse files Browse the repository at this point in the history
  • Loading branch information
yashlamba committed Dec 17, 2024
1 parent 942ac3f commit 2cf5ec2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions site/zenodo_rdm/curation/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
award_acronym_in_additional_description,
award_acronym_in_description,
award_acronym_in_title,
community_name_award_acronym,
contains_high_conf_keywords,
contains_low_conf_keywords,
eu_community_declined_request,
Expand All @@ -35,6 +36,7 @@
"award_acronym_in_additional_description": award_acronym_in_additional_description,
"eu_community_declined_request": eu_community_declined_request,
"eu_subcommunity_declined_request": eu_subcommunity_declined_request,
"community_name_award_acronym": community_name_award_acronym,
}
"""Rules to run for EU Curation."""

Expand All @@ -51,6 +53,7 @@
"award_acronym_in_additional_description": 0,
"eu_community_declined_request": False,
"eu_subcommunity_declined_request": False,
"community_name_award_acronym": 0,
}
"""Rule scores for EU Curation (bool value implies direct approval/decline)."""

Expand Down
21 changes: 21 additions & 0 deletions site/zenodo_rdm/curation/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,24 @@ def eu_subcommunity_declined_request(record):
if result["status"] == "declined":
return True
return False


def community_name_award_acronym(record):
"""Check if award acronym in community name."""
comm_text = ""
for comm in record.parent.communities:
comm_text += comm.metadata.get("title", "")
comm_text += comm.metadata.get("page", "")

if comm_text:
award_service = current_service_registry.get("awards")
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("acronym") and (
award.get("acronym").lower() in comm_text.lower()
):
return True
return False

0 comments on commit 2cf5ec2

Please sign in to comment.