{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Step 1: Create Assets from Raw PDFs\n", "\n", "This notebook processes raw PDFs and creates structured assets:\n", "- Page images (PNG at 300 DPI)\n", "- OCR text (AWS Textract)\n", "\n", "**Output**: Structured assets for benchmark creation" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import sys\n", "sys.path.append(\"../src/assets\")\n", "\n", "from services.pdf_loader import PdfLoader\n", "from services.textract_ocr import TextractOcr\n", "from services.asset_writer import AssetWriter\n", "from services.asset_creator import AssetCreator" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Configuration" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "RAW_DATA_PATH = '../data/raw_pdfs'\n", "OUTPUT_PATH = '../data/assets'\n", "WORKERS = 10\n", "LIMIT = None # Set to number to limit processing" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Load PDFs" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "loader = PdfLoader(raw_data_path=RAW_DATA_PATH)\n", "documents = loader.get_all_documents()\n", "\n", "print(f\"Loaded {len(documents)} documents\")\n", "print(f\"Sample: {documents[0]}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Create Assets" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ocr = TextractOcr()\n", "writer = AssetWriter(output_base_path=OUTPUT_PATH)\n", "creator = AssetCreator(writer, ocr)\n", "\n", "results = creator.create_all(\n", " documents=documents,\n", " workers=WORKERS,\n", " limit=LIMIT\n", ")\n", "\n", "print(f\"\\nResults: {results}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Save Document Mapping (Optional)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "loader.save_document_mapping(\n", " documents,\n", " output_path='../data/document_mapping.csv'\n", ")\n", "\n", "print(\"Document mapping saved!\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python", "version": "3.8.0" } }, "nbformat": 4, "nbformat_minor": 4 }