|
364 | 364 | "metadata": {}, |
365 | 365 | "outputs": [], |
366 | 366 | "source": [ |
367 | | - "from idp_common.s3 import get_json_content\n", |
368 | | - "\n", |
369 | 367 | "print(\"\\nShow extraction results...\\n\")\n", |
370 | 368 | "\n", |
371 | 369 | "document_dict = document.to_dict()\n", |
372 | 370 | "sections_json = json.dumps(document_dict[\"sections\"][:n], indent=2)\n", |
373 | | - "print(sections_json)\n", |
| 371 | + "print(f\"{sections_json}...\")\n", |
374 | 372 | "\n", |
375 | 373 | "for section in document.sections[:n]:\n", |
376 | 374 | " print(f\"\\nSection {section.section_id} extraction result:\")\n", |
377 | 375 | " extraction_result_uri = section.extraction_result_uri\n", |
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)" |
| 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\"])" |
382 | 381 | ] |
383 | 382 | }, |
384 | 383 | { |
|
0 commit comments