From e109996661a2b0f89e226b96e525c04dfdd952c1 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 10 Nov 2021 15:34:13 -0800 Subject: grobid_tool: helper to process a single file --- python/grobid_tool.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'python') diff --git a/python/grobid_tool.py b/python/grobid_tool.py index 782bc13..029cbf1 100755 --- a/python/grobid_tool.py +++ b/python/grobid_tool.py @@ -18,6 +18,13 @@ from sandcrawler import * from sandcrawler.grobid import CrossrefRefsWorker +def run_single(args): + grobid_client = GrobidClient(host_url=args.grobid_host) + resp = grobid_client.process_fulltext(blob=args.pdf_file.read()) + resp["_metadata"] = grobid_client.metadata(resp) + print(json.dumps(resp, sort_keys=True)) + + def run_extract_json(args): grobid_client = GrobidClient(host_url=args.grobid_host) wayback_client = WaybackClient() @@ -113,6 +120,14 @@ def main(): ) subparsers = parser.add_subparsers() + sub_single = subparsers.add_parser("single") + sub_single.set_defaults(func=run_single) + sub_single.add_argument( + "pdf_file", + help="path to PDF file to process", + type=argparse.FileType("rb"), + ) + sub_extract_json = subparsers.add_parser( "extract-json", help="for each JSON line with CDX info, fetches PDF and does GROBID extraction", -- cgit v1.2.3