|
364 | 364 | "metadata": {}, |
365 | 365 | "outputs": [], |
366 | 366 | "source": [ |
| 367 | + "from idp_common.s3 import get_json_content\n", |
| 368 | + "\n", |
367 | 369 | "print(\"\\nShow extraction results...\\n\")\n", |
368 | 370 | "\n", |
369 | 371 | "document_dict = document.to_dict()\n", |
370 | 372 | "sections_json = json.dumps(document_dict[\"sections\"][:n], indent=2)\n", |
371 | | - "print(f\"{sections_json}...\")\n", |
| 373 | + "print(sections_json)\n", |
372 | 374 | "\n", |
373 | 375 | "for section in document.sections[:n]:\n", |
374 | 376 | " print(f\"\\nSection {section.section_id} extraction result:\")\n", |
375 | 377 | " extraction_result_uri = section.extraction_result_uri\n", |
376 | | - " bucket, key = parse_s3_uri(extraction_result_uri)\n", |
377 | | - " response = s3_client.get_object(Bucket=bucket, Key=key)\n", |
378 | | - " content = response['Body'].read().decode('utf-8')\n", |
379 | | - " result = json.loads(content)\n", |
380 | | - " pprint.pp(result[\"inference_result\"])" |
| 378 | + " if extraction_result_uri:\n", |
| 379 | + " result = get_json_content(extraction_result_uri)\n", |
| 380 | + " result_json = json.dumps(result[\"inference_result\"], indent=2)\n", |
| 381 | + " print(result_json)" |
381 | 382 | ] |
382 | 383 | }, |
383 | 384 | { |
|
0 commit comments