Skip to content

Commit

Permalink
Merge pull request #100 from MJedr/handle-empty-pubino-freetext
Browse files Browse the repository at this point in the history
app: handle empty pubinfo_freetext when extracting journal reference
  • Loading branch information
drjova authored Jun 8, 2022
2 parents 4247aaf + ab7608b commit a3362a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions refextract/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def extract_journal_info(args):
journal_dict = {"journals": journal_kb_data}
try:
for publication_info in publication_infos:
if not publication_info.get('pubinfo_freetext'):
extracted_publication_infos.append({})
continue
extracted_publication_info = extract_journal_reference(
publication_info["pubinfo_freetext"],
override_kbs_files=journal_dict,
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_extract_journal_info(app_client):
"BULLETIN OF THE CALCUTTA MATHEMATICAL SOCIETY": "Bull.Calcutta Math.Soc.",
"QUANTUM MACHINE INTELLIGENCE": "Quantum Machine Intelligence",
}
publication_infos = [{"pubinfo_freetext": "Phys. Rev. 127 (1962) 965-970"}]
publication_infos = [{"pubinfo_freetext": "Phys. Rev. 127 (1962) 965-970"}, {"journal_title": "Phys. Rev."}]

payload = {
"journal_kb_data": journal_kb_data,
Expand All @@ -37,7 +37,7 @@ def test_extract_journal_info(app_client):
)
assert response.status_code == 200
assert "extracted_publication_infos" in response.json
assert len(response.json["extracted_publication_infos"]) == 1
assert len(response.json["extracted_publication_infos"]) == 2


@mock.patch("refextract.app.extract_journal_reference", side_effect=KeyError("test message"))
Expand Down

0 comments on commit a3362a7

Please sign in to comment.