From 33211915773a0c77d064c55c1b02ceed6f455feb Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 27 Oct 2021 15:33:29 -0700 Subject: replace grobid2json with grobid_tei_xml This first iteration uses the .to_legacy_dict() helpers for backwards compatibility --- tests/test_grobid2json.py | 11 ++++++++--- tests/test_refs_transform.py | 5 +++-- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/test_grobid2json.py b/tests/test_grobid2json.py index 345fd91..adf36a1 100644 --- a/tests/test_grobid2json.py +++ b/tests/test_grobid2json.py @@ -1,12 +1,17 @@ -from fatcat_scholar.grobid2json import teixml2json +from grobid_tei_xml import parse_document_xml -def test_grobid_teixml2json() -> None: +def test_grobid_parse() -> None: + """ + This function formerly tested the grobid2json file in this project. Now it + tests backwards-compatibility of the grobid_tei_xml library. + """ with open("tests/files/example_grobid.tei.xml", "r") as f: blob = f.read() - obj = teixml2json(blob, True) + doc = parse_document_xml(blob) + obj = doc.to_legacy_dict() assert ( obj["title"] diff --git a/tests/test_refs_transform.py b/tests/test_refs_transform.py index 5f15adf..2fc210f 100644 --- a/tests/test_refs_transform.py +++ b/tests/test_refs_transform.py @@ -1,8 +1,8 @@ import json from fatcat_openapi_client import ReleaseEntity +from grobid_tei_xml import parse_document_xml -from fatcat_scholar.grobid2json import teixml2json from fatcat_scholar.transform import refs_from_crossref, refs_from_grobid @@ -19,7 +19,8 @@ def test_transform_refs_grobid() -> None: ext_ids={}, ) - tei_dict = teixml2json(blob, True) + tei_doc = parse_document_xml(blob) + tei_dict = tei_doc.to_legacy_dict() refs = refs_from_grobid(dummy_release, tei_dict) ref = refs[12] -- cgit v1.2.3