|
390 | 390 | "metadata": {}, |
391 | 391 | "outputs": [], |
392 | 392 | "source": [ |
| 393 | + "from idp_common.s3 import get_json_content\n", |
| 394 | + "\n", |
393 | 395 | "print(\"\\nShow extraction results...\\n\")\n", |
394 | 396 | "\n", |
395 | 397 | "document_dict = document.to_dict()\n", |
396 | 398 | "sections_json = json.dumps(document_dict[\"sections\"][:n], indent=2)\n", |
397 | | - "print(f\"{sections_json}...\")\n", |
| 399 | + "print(sections_json)\n", |
398 | 400 | "\n", |
399 | 401 | "for section in document.sections[:n]:\n", |
400 | 402 | " print(f\"\\nSection {section.section_id} extraction result:\")\n", |
401 | 403 | " extraction_result_uri = section.extraction_result_uri\n", |
402 | | - " bucket, key = parse_s3_uri(extraction_result_uri)\n", |
403 | | - " response = s3_client.get_object(Bucket=bucket, Key=key)\n", |
404 | | - " content = response['Body'].read().decode('utf-8')\n", |
405 | | - " result = json.loads(content)\n", |
406 | | - " pprint.pp(result[\"inference_result\"])" |
| 404 | + " if extraction_result_uri:\n", |
| 405 | + " result = get_json_content(extraction_result_uri)\n", |
| 406 | + " result_json = json.dumps(result[\"inference_result\"], indent=2)\n", |
| 407 | + " print(result_json)" |
407 | 408 | ] |
408 | 409 | }, |
409 | 410 | { |
|
0 commit comments