Skip to content

Commit

Permalink
normailize journal titles: use hep request
Browse files Browse the repository at this point in the history
  • Loading branch information
MJedr committed Nov 9, 2023
1 parent 4604f3a commit b9f5bfb
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions inspirehep/modules/workflows/tasks/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,21 +638,29 @@ def normalize_journal_titles(obj, eng):
normalize_journal_title_entry(obj, publication, add_inspire_categories=True)

references = obj.data.get("references", [])
reference_journal_titles = get_value(references, 'reference.publication_info.journal_title', [])
response = requests.post(
"{inspirehep_url}/curation/literature/normalize-journal-titles".format(
inspirehep_url=current_app.config["INSPIREHEP_URL"]
),
headers=_get_headers_for_hep_root_table_request(),
data=json.dumps({'journal_titles_list': reference_journal_titles})
)
response.raise_for_status()
normalized_journal_titles_mapping = response.json()['normalized_journal_titles']
for reference in references:
publication_info = get_value(reference, 'reference.publication_info')
if not publication_info:
publication_info = get_value(reference, 'reference.publication_info', {})
journal_title = publication_info.get('journal_title')
if not journal_title:
continue
normalize_journal_title_entry(obj, publication_info)
normalized_joutnal_title = normalized_journal_titles_mapping['journal_title']
normalize_journal_title_entry(obj, publication_info, normalized_joutnal_title)

if obj.extra_data.get('journal_inspire_categories'):
obj.extra_data['journal_inspire_categories'] = dedupe_list(obj.extra_data['journal_inspire_categories'])


def normalize_journal_title_entry(obj, publication_info, add_inspire_categories=False):
if 'journal_title' not in publication_info:
return

normalized_title = normalize_journal_title(publication_info['journal_title'])
def normalize_journal_title_entry(obj, publication_info, normalized_title, add_inspire_categories=False):
publication_info['journal_title'] = normalized_title

ref_query = RecordMetadata.query.filter(
Expand Down

0 comments on commit b9f5bfb

Please sign in to comment.