Skip to content

Commit

Permalink
add classifier keywords remove script (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalEgn authored Sep 16, 2024
1 parent c4d4f74 commit 1d04298
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
11 changes: 11 additions & 0 deletions scripts/remove-classifier-keywords/kustomization.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../../base/script-job

configMapGenerator:
- name: hep-script
files:
- script.py
nameSuffix: -remove-classifier-keywords
31 changes: 31 additions & 0 deletions scripts/remove-classifier-keywords/script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from inspire_utils.record import get_value
from inspirehep.curation.search_check_do import SearchCheckDo


class RemoveClassifierKeywords(SearchCheckDo):
query = "keywords.source:classifier"

@staticmethod
def check(record, logger, state):
if any(
keyword.get("source", "") == "classifier"
for keyword in get_value(record, "keywords", [])
):
return True
else:
return False

@staticmethod
def do(record, logger, state):
new_keywords = [
keyword
for keyword in record.get("keywords", [])
if keyword.get("source", "") != "classifier"
]
if new_keywords:
record["keywords"] = new_keywords
else:
del record["keywords"]


RemoveClassifierKeywords()

0 comments on commit 1d04298

Please sign in to comment.