From 2f41335d268b0e2705a1ebff0ff104e965630837 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 28 Oct 2021 14:00:36 -0700 Subject: use grobid_tei_xml for grobid unstructured lookups --- tests/test_grobid_unstructured.py | 58 +++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 26 deletions(-) (limited to 'tests') diff --git a/tests/test_grobid_unstructured.py b/tests/test_grobid_unstructured.py index dd69936..cf71f91 100644 --- a/tests/test_grobid_unstructured.py +++ b/tests/test_grobid_unstructured.py @@ -1,39 +1,43 @@ import pytest -from fuzzycat.grobid_unstructured import grobid_api_process_citation, grobid_parse_unstructured, grobid_ref_to_release, transform_grobid_ref_xml +from grobid_tei_xml import parse_citation_xml +from grobid_tei_xml.types import GrobidBiblio, GrobidAuthor + +from fuzzycat.grobid_unstructured import grobid_api_process_citation, grobid_parse_unstructured, grobid_ref_to_release def test_grobid_ref_to_release(): - d = { - 'title': - "some title", - 'doi': - '10.1234/5678', - 'journal': - 'some journal', - 'authors': [ - { - 'name': 'ahab sailor', - 'given_name': 'ahab', - 'surname': 'sailor' - }, - { - 'name': 'mary jane', - 'given_name': 'mary', - 'surname': 'jane' - }, + d = GrobidBiblio( + title="some title", + doi='10.1234/5678', + journal='some journal', + authors=[ + GrobidAuthor( + full_name='ahab sailor', + given_name='ahab', + surname='sailor', + ), + GrobidAuthor( + full_name='mary jane', + given_name='mary', + surname='jane' + ), ], - } + ) r = grobid_ref_to_release(d) - assert r.title == d['title'] - assert r.ext_ids.doi == d['doi'] - assert r.extra['container_name'] == d['journal'] - assert r.contribs[0].surname == d['authors'][0]['surname'] - assert r.contribs[1].raw_name == d['authors'][1]['name'] + assert r.title == d.title + assert r.ext_ids.doi == d.doi + assert r.extra['container_name'] == d.journal + assert r.contribs[0].surname == d.authors[0].surname + assert r.contribs[1].raw_name == d.authors[1].full_name def test_transform_grobid_ref_xml(): + """ + This used to be a test of the grobid2json file in this repository. Now it + is a backwards compatibility test for grobid_tei_xml + """ citation_xml = """ @@ -83,7 +87,9 @@ def test_transform_grobid_ref_xml(): """ - d = transform_grobid_ref_xml(citation_xml) + citation = parse_citation_xml(citation_xml) + assert citation + d = citation.to_legacy_dict() assert d['title'] == "Mesh migration following abdominal hernia repair: a comprehensive review" assert d['authors'][2]['given_name'] == "L" assert d['authors'][2]['surname'] == "Taveras" -- cgit v1.2.3