Arrange all the questions according to physiology chapters priority vice
python3 << 'EOF' import pdfplumber pdf_path = "/home/daytona/workspace/attachments/157cace8-9dfa-4e04-9040-855f584519bd/Physiology prvs 15 yrs @Medi Circle.pdf" with pdfplumber.open(pdf_path) as pdf: print(f"Total pages: {len(pdf.pages)}") # Extract first 5 pages to understand structure for i, page in enumerate(pdf.pages[:5]): text = page.extract_text() print(f"\n--- PAGE {i+1} ---") print(text) EOF
python3 << 'EOF' import pdfplumber from pypdf import PdfReader pdf_path = "/home/daytona/workspace/attachments/157cace8-9dfa-4e04-9040-855f584519bd/Physiology prvs 15 yrs @Medi Circle.pdf" # Try pypdf reader = PdfReader(pdf_path) print(f"Total pages: {len(reader.pages)}") for i in range(min(5, len(reader.pages))): text = reader.pages[i].extract_text() print(f"\n--- PAGE {i+1} ---") print(repr(text[:500]) if text else "EMPTY") EOF
python3 << 'EOF' # Check available OCR tools import subprocess result = subprocess.run(['which', 'tesseract'], capture_output=True, text=True) print("tesseract:", result.stdout.strip()) result2 = subprocess.run(['python3', '-c', 'import pdf2image; print("pdf2image ok")'], capture_output=True, text=True) print(result2.stdout, result2.stderr) result3 = subprocess.run(['python3', '-c', 'import pytesseract; print("pytesseract ok")'], capture_output=True, text=True) print(result3.stdout, result3.stderr) result4 = subprocess.run(['which', 'pdftoppm'], capture_output=True, text=True) print("pdftoppm:", result4.stdout.strip()) EOF
python3 << 'EOF' from pdf2image import convert_from_path import pytesseract pdf_path = "/home/daytona/workspace/attachments/157cace8-9dfa-4e04-9040-855f584519bd/Physiology prvs 15 yrs @Medi Circle.pdf" # Convert all pages to images and OCR pages = convert_from_path(pdf_path, dpi=200) print(f"Converted {len(pages)} pages") full_text = [] for i, page in enumerate(pages): text = pytesseract.image_to_string(page) full_text.append(f"\n=== PAGE {i+1} ===\n{text}") if i < 3: print(f"\n--- PAGE {i+1} PREVIEW ---") print(text[:300]) # Save full text with open("/home/daytona/workspace/physiology_ocr.txt", "w") as f: f.write("\n".join(full_text)) print("\nSaved to physiology_ocr.txt") EOF
python3 << 'EOF' from pdf2image import convert_from_path import pytesseract pdf_path = "/home/daytona/workspace/attachments/157cace8-9dfa-4e04-9040-855f584519bd/Physiology prvs 15 yrs @Medi Circle.pdf" full_text = [] # Process 5 pages at a time to avoid OOM for batch_start in range(2, 51, 5): # Skip page 1 (cover), process 2-50 batch_end = min(batch_start + 4, 50) pages = convert_from_path(pdf_path, dpi=150, first_page=batch_start, last_page=batch_end) for j, page in enumerate(pages): page_num = batch_start + j text = pytesseract.image_to_string(page) full_text.append(f"\n=== PAGE {page_num} ===\n{text}") print(f"Done pages {batch_start}-{batch_end}") with open("/home/daytona/workspace/physiology_ocr.txt", "w") as f: f.write("\n".join(full_text)) print("Saved!") EOF
python3 << 'EOF' from pdf2image import convert_from_path import pytesseract pdf_path = "/home/daytona/workspace/attachments/157cace8-9dfa-4e04-9040-855f584519bd/Physiology prvs 15 yrs @Medi Circle.pdf" # Process just pages 2-10 first to understand structure pages = convert_from_path(pdf_path, dpi=120, first_page=2, last_page=10) print(f"Got {len(pages)} pages") for j, page in enumerate(pages): text = pytesseract.image_to_string(page) print(f"\n=== PAGE {j+2} ===") print(text[:800]) print("---") EOF
python3 << 'EOF' from pdf2image import convert_from_path import pytesseract pdf_path = "/home/daytona/workspace/attachments/157cace8-9dfa-4e04-9040-855f584519bd/Physiology prvs 15 yrs @Medi Circle.pdf" all_text = {} # Process pages 2-25 pages = convert_from_path(pdf_path, dpi=120, first_page=2, last_page=25) for j, page in enumerate(pages): page_num = j + 2 text = pytesseract.image_to_string(page) all_text[page_num] = text import json with open("/home/daytona/workspace/ocr_p2_25.json", "w") as f: json.dump(all_text, f) print("Done pages 2-25") EOF
python3 << 'EOF' from pdf2image import convert_from_path import pytesseract import json pdf_path = "/home/daytona/workspace/attachments/157cace8-9dfa-4e04-9040-855f584519bd/Physiology prvs 15 yrs @Medi Circle.pdf" all_text = {} pages = convert_from_path(pdf_path, dpi=120, first_page=26, last_page=50) for j, page in enumerate(pages): page_num = j + 26 text = pytesseract.image_to_string(page) all_text[page_num] = text with open("/home/daytona/workspace/ocr_p26_50.json", "w") as f: json.dump(all_text, f) print("Done pages 26-50") EOF
python3 << 'EOF' from pdf2image import convert_from_path import pytesseract import json pdf_path = "/home/daytona/workspace/attachments/157cace8-9dfa-4e04-9040-855f584519bd/Physiology prvs 15 yrs @Medi Circle.pdf" all_text = {} pages = convert_from_path(pdf_path, dpi=120, first_page=26, last_page=38) for j, page in enumerate(pages): page_num = j + 26 text = pytesseract.image_to_string(page) all_text[page_num] = text with open("/home/daytona/workspace/ocr_p26_38.json", "w") as f: json.dump(all_text, f) print("Done pages 26-38") EOF