Can you extract the Question of pathology according to system
python3 << 'EOF' import pdfplumber import os base = "/home/daytona/workspace/attachments/41d9b23c-58d6-4923-b4df-0a710b771a9f/" files = [ "prelims paper (1).pdf", "PDU prelims 2025.pdf", "2nd year Uni exam Fab 2024.pdf", "22 Batch Prelims 2nd Year.pdf", "University 2nd Year 2024.pdf" ] for fname in files: fpath = base + fname print(f"\n{'='*80}") print(f"FILE: {fname}") print('='*80) try: with pdfplumber.open(fpath) as pdf: for i, page in enumerate(pdf.pages): text = page.extract_text() if text: print(f"\n--- Page {i+1} ---") print(text) except Exception as e: print(f"ERROR: {e}") EOF
python3 << 'EOF' import subprocess import os base = "/home/daytona/workspace/attachments/41d9b23c-58d6-4923-b4df-0a710b771a9f/" files = [ "prelims paper (1).pdf", "PDU prelims 2025.pdf", "2nd year Uni exam Fab 2024.pdf", "22 Batch Prelims 2nd Year.pdf", "University 2nd Year 2024.pdf" ] out_dir = "/home/daytona/workspace/pdf_ocr/" os.makedirs(out_dir, exist_ok=True) for fname in files: fpath = base + fname safe_name = fname.replace(" ", "_").replace("(", "").replace(")", "").replace(".pdf", "") out_txt = out_dir + safe_name + ".txt" print(f"Processing: {fname}") result = subprocess.run( ["ocrmypdf", "--force-ocr", "--sidecar", out_txt, fpath, "/dev/null"], capture_output=True, text=True, timeout=180 ) print(f" Return code: {result.returncode}") if result.returncode == 0: print(f" Saved to: {out_txt}") else: print(f" STDERR: {result.stderr[:300]}") print("\nDone") EOF
python3 << 'EOF' import fitz # PyMuPDF import os base = "/home/daytona/workspace/attachments/41d9b23c-58d6-4923-b4df-0a710b771a9f/" files = [ "prelims paper (1).pdf", "PDU prelims 2025.pdf", "2nd year Uni exam Fab 2024.pdf", "22 Batch Prelims 2nd Year.pdf", "University 2nd Year 2024.pdf" ] out_dir = "/home/daytona/workspace/pdf_ocr/" os.makedirs(out_dir, exist_ok=True) for fname in files: fpath = base + fname safe_name = fname.replace(" ", "_").replace("(", "").replace(")", "").replace(".pdf", "") out_txt = out_dir + safe_name + ".txt" print(f"\nProcessing: {fname}") try: doc = fitz.open(fpath) all_text = [] for i, page in enumerate(doc): text = page.get_text() if text.strip(): all_text.append(f"--- Page {i+1} ---\n{text}") if all_text: combined = "\n".join(all_text) with open(out_txt, "w") as f: f.write(combined) print(f" Extracted {len(all_text)} pages with text, saved to {out_txt}") print(f" Preview:\n{combined[:500]}") else: print(f" No text found (likely scanned image PDF)") # Check page count print(f" Page count: {len(doc)}") # Try to get pixmap to confirm images exist page = doc[0] pix = page.get_pixmap() print(f" Page 1 pixmap size: {pix.width}x{pix.height}") except Exception as e: print(f" ERROR: {e}") print("\nAll done.") EOF
python3 -c "import pypdf; print('pypdf ok')" 2>&1; python3 -c "import pdf2image; print('pdf2image ok')" 2>&1; python3 -c "import pytesseract; print('pytesseract ok')" 2>&1; which tesseract 2>&1; which pdftoppm 2>&1; which pdftotext 2>&1
python3 << 'EOF' from pdf2image import convert_from_path import pytesseract import os base = "/home/daytona/workspace/attachments/41d9b23c-58d6-4923-b4df-0a710b771a9f/" files = [ "prelims paper (1).pdf", "PDU prelims 2025.pdf", "2nd year Uni exam Fab 2024.pdf", "22 Batch Prelims 2nd Year.pdf", "University 2nd Year 2024.pdf" ] out_dir = "/home/daytona/workspace/pdf_ocr/" os.makedirs(out_dir, exist_ok=True) for fname in files: fpath = base + fname safe_name = fname.replace(" ", "_").replace("(", "").replace(")", "").replace(".pdf", "") out_txt = out_dir + safe_name + ".txt" print(f"\nProcessing: {fname} ...") try: images = convert_from_path(fpath, dpi=200) print(f" Pages: {len(images)}") all_text = [] for i, img in enumerate(images): text = pytesseract.image_to_string(img) all_text.append(f"--- Page {i+1} ---\n{text}") combined = "\n".join(all_text) with open(out_txt, "w") as f: f.write(combined) print(f" Saved to {out_txt}") print(f" Preview (first 400 chars):\n{combined[:400]}") except Exception as e: print(f" ERROR: {e}") print("\nAll PDFs processed.") EOF
python3 << 'EOF' # Read all OCR text files and print subjects found import os out_dir = "/home/daytona/workspace/pdf_ocr/" files = [ "prelims_paper_1.txt", "PDU_prelims_2025.txt", "2nd_year_Uni_exam_Fab_2024.txt", "22_Batch_Prelims_2nd_Year.txt", "University_2nd_Year_2024.txt" ] for fname in files: fpath = out_dir + fname with open(fpath) as f: content = f.read() # Print first 1500 chars to identify subject print(f"\n{'='*60}") print(f"FILE: {fname}") print(f"TOTAL LENGTH: {len(content)}") print(f"FIRST 1500 CHARS:") print(content[:1500]) EOF
python3 << 'EOF' # Read full prelims_paper_1.txt - this has Pathology with open("/home/daytona/workspace/pdf_ocr/prelims_paper_1.txt") as f: content = f.read() print(content) EOF
ls /home/daytona/workspace/ && ls /home/daytona/skills/docx/scripts/office/ 2>/dev/null || echo "No scripts/office dir"
mkdir -p /home/daytona/workspace/pathology-questions && cat > /home/daytona/workspace/pathology-questions/create_doc.js << 'JSEOF' const { Document, Packer, Paragraph, TextRun, HeadingLevel, AlignmentType, BorderStyle } = require('docx'); const fs = require('fs'); const doc = new Document({ styles: { default: { document: { run: { font: "Calibri", size: 24 } } } }, sections: [{ children: [ // Title new Paragraph({ text: "PATHOLOGY QUESTIONS - ORGANIZED BY SYSTEM", heading: HeadingLevel.TITLE, alignment: AlignmentType.CENTER, }), new Paragraph({ children: [new TextRun({ text: "Sources: Shantabaa Medical College, Amreli - 2nd Year MBBS Preliminary Examination (2025)", italics: true, size: 20 })], alignment: AlignmentType.CENTER, }), new Paragraph({ text: "" }), // ============================================================ // SECTION 1: GENERAL PATHOLOGY // ============================================================ new Paragraph({ text: "1. GENERAL PATHOLOGY", heading: HeadingLevel.HEADING_1 }), // 1.1 Cell Injury & Necrosis new Paragraph({ text: "1.1 Cell Injury, Necrosis & Apoptosis", heading: HeadingLevel.HEADING_2 }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q4(C): ", bold: true }), new TextRun("Write definition of apoptosis.")] }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q4(B): ", bold: true }), new TextRun("Sentence regarding tuberculosis is True or False: \"Caseation necrosis seen in tuberculosis is only liquefactive type of necrosis.\"")] }), new Paragraph({ text: "" }), // 1.2 Inflammation & Healing new Paragraph({ text: "1.2 Inflammation & Wound Healing", heading: HeadingLevel.HEADING_2 }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q2(A): ", bold: true }), new TextRun("Describe healing by first intension (primary union).")] }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q3(A): ", bold: true }), new TextRun("Difference between transudate and exudate.")] }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q1 (Long Essay): ", bold: true }), new TextRun("Define shock. Enumerate the classification and etiology of shock. Describe pathogenesis of septic shock. Describe the stages of shock.")] }), new Paragraph({ text: "" }), // 1.3 Edema & Fluid Disturbances new Paragraph({ text: "1.3 Edema & Fluid Disturbances", heading: HeadingLevel.HEADING_2 }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q2(D): ", bold: true }), new TextRun("Define Edema. Write pathophysiology of edema.")] }), new Paragraph({ text: "" }), // 1.4 Pigments & Deposits new Paragraph({ text: "1.4 Pigments & Deposits", heading: HeadingLevel.HEADING_2 }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q3(B): ", bold: true }), new TextRun("Exogenous pigments.")] }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q4(D): ", bold: true }), new TextRun("Pneumoconiosis.")] }), new Paragraph({ text: "" }), // 1.5 Hypersensitivity & Immunology new Paragraph({ text: "1.5 Hypersensitivity & Immunology", heading: HeadingLevel.HEADING_2 }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q4(E): ", bold: true }), new TextRun("Write two examples of type I hypersensitivity reaction.")] }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q4(D): ", bold: true }), new TextRun("What is opportunistic infection and give example of it.")] }), new Paragraph({ text: "" }), // 1.6 Genetics & Chromosomal Disorders new Paragraph({ text: "1.6 Genetics & Chromosomal Disorders", heading: HeadingLevel.HEADING_2 }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q3(C): ", bold: true }), new TextRun("Clinical features and cytogenetic abnormalities of Down Syndrome.")] }), new Paragraph({ text: "" }), // 1.7 Nutritional Disorders new Paragraph({ text: "1.7 Nutritional Disorders", heading: HeadingLevel.HEADING_2 }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q3(D): ", bold: true }), new TextRun("Enumerate difference between Kwashiorkor disease and Marasmus.")] }), new Paragraph({ text: "" }), // ============================================================ // SECTION 2: NEOPLASIA / ONCOLOGY // ============================================================ new Paragraph({ text: "2. NEOPLASIA / ONCOLOGY", heading: HeadingLevel.HEADING_1 }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q2(B): ", bold: true }), new TextRun("Enumerate the contrasting features of initiator and promoter carcinogens.")] }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q2(C): ", bold: true }), new TextRun("Describe paraneoplastic syndrome.")] }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q4(A): ", bold: true }), new TextRun("Write routes of tumor spread.")] }), new Paragraph({ text: "" }), // ============================================================ // SECTION 3: CARDIOVASCULAR SYSTEM // ============================================================ new Paragraph({ text: "3. CARDIOVASCULAR SYSTEM", heading: HeadingLevel.HEADING_1 }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q1 (Long Essay): ", bold: true }), new TextRun("Describe the Pathogenesis, Pathology, presenting and distinguishing features, and complications of Bacterial Endocarditis.")] }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q3(A): ", bold: true }), new TextRun("Rheumatic Heart Disease.")] }), new Paragraph({ text: "" }), // ============================================================ // SECTION 4: RESPIRATORY SYSTEM // ============================================================ new Paragraph({ text: "4. RESPIRATORY SYSTEM", heading: HeadingLevel.HEADING_1 }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q2(B): ", bold: true }), new TextRun("Emphysema.")] }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q3(D): ", bold: true }), new TextRun("Lobar Pneumonia.")] }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q4(A): ", bold: true }), new TextRun("\"Commonly presents with salty sweat in infancy.\" Is the statement true or false in regard to cystic fibrosis?")] }), new Paragraph({ text: "" }), // ============================================================ // SECTION 5: GASTROINTESTINAL SYSTEM // ============================================================ new Paragraph({ text: "5. GASTROINTESTINAL SYSTEM", heading: HeadingLevel.HEADING_1 }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q2(A): ", bold: true }), new TextRun("Non-alcoholic steatohepatitis (NASH).")] }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q3(C): ", bold: true }), new TextRun("Peptic ulcer.")] }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q4(B): ", bold: true }), new TextRun("Mention 2 complications of chronic Pancreatitis.")] }), new Paragraph({ text: "" }), // ============================================================ // SECTION 6: URINARY SYSTEM // ============================================================ new Paragraph({ text: "6. URINARY SYSTEM (KIDNEY & URINARY TRACT)", heading: HeadingLevel.HEADING_1 }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q2(C): ", bold: true }), new TextRun("Pyelonephritis.")] }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q4(C): ", bold: true }), new TextRun("Enumerate causes of small contracted kidney.")] }), new Paragraph({ text: "" }), // ============================================================ // SECTION 7: MALE REPRODUCTIVE SYSTEM // ============================================================ new Paragraph({ text: "7. MALE REPRODUCTIVE SYSTEM", heading: HeadingLevel.HEADING_1 }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q4(D): ", bold: true }), new TextRun("Benign Prostatic Hyperplasia.")] }), new Paragraph({ text: "" }), // ============================================================ // SECTION 8: FEMALE REPRODUCTIVE SYSTEM // ============================================================ new Paragraph({ text: "8. FEMALE REPRODUCTIVE SYSTEM", heading: HeadingLevel.HEADING_1 }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q2(D): ", bold: true }), new TextRun("Classification of ovarian tumors.")] }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q3(B): ", bold: true }), new TextRun("Fibroadenoma.")] }), new Paragraph({ text: "" }), // ============================================================ // SECTION 9: ENDOCRINE SYSTEM // ============================================================ new Paragraph({ text: "9. ENDOCRINE SYSTEM", heading: HeadingLevel.HEADING_1 }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q4(E): ", bold: true }), new TextRun("Hypothyroidism.")] }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q4(F): ", bold: true }), new TextRun("Enumerate laboratory tests for gout.")] }), new Paragraph({ text: "" }), // ============================================================ // SECTION 10: HAEMATOLOGY // ============================================================ new Paragraph({ text: "10. HAEMATOLOGY (BLOOD & BONE MARROW)", heading: HeadingLevel.HEADING_1 }), // 10.1 Anaemia new Paragraph({ text: "10.1 Anaemia", heading: HeadingLevel.HEADING_2 }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q5 (Long Essay): ", bold: true }), new TextRun("A 50-year male vegetarian presented with pallor, paresthesia of extremities - What is your diagnosis? How will you investigate further and establish the diagnosis? Classify BC disorders according to etiology.")] }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q7(D): ", bold: true }), new TextRun("A 20-year female had hematocrit of 20%, reticulocytosis, hyperbilirubinemia, peripheral smear revealed anisopoikilocytosis and target cells. What is the pathophysiology of this disease?")] }), new Paragraph({ text: "" }), // 10.2 Haemostasis & Coagulation Disorders new Paragraph({ text: "10.2 Haemostasis & Coagulation Disorders", heading: HeadingLevel.HEADING_2 }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q6(A): ", bold: true }), new TextRun("Haemophilia.")] }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q7(B): ", bold: true }), new TextRun("Etiopathogenesis of ITP (Idiopathic Thrombocytopenic Purpura).")] }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q8(B): ", bold: true }), new TextRun("Enumerate two functional platelet disorders.")] }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q7(C): ", bold: true }), new TextRun("PCV estimation and its significance.")] }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q8(E): ", bold: true }), new TextRun("Stains used in haematology.")] }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q8(F): ", bold: true }), new TextRun("What is Coombs' test?")] }), new Paragraph({ text: "" }), // 10.3 Sickle Cell Disease new Paragraph({ text: "10.3 Sickle Cell Disease", heading: HeadingLevel.HEADING_2 }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q6(B): ", bold: true }), new TextRun("Write in detail about pathogenesis and investigation of sickle cell disease.")] }), new Paragraph({ text: "" }), // 10.4 Lymphoma & Leukaemia new Paragraph({ text: "10.4 Lymphoma & Leukaemia", heading: HeadingLevel.HEADING_2 }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q6(C): ", bold: true }), new TextRun("How is Hodgkin's lymphoma classified? Name, describe and draw the cell which is hallmark of Hodgkin's Lymphoma.")] }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q6(D): ", bold: true }), new TextRun("A 18-year male friend diagnosed as Hodgkin's lymphoma. How will you empathize with him and his family members & support them? (AETCOM)")] }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q7(A): ", bold: true }), new TextRun("A 30-year male with splenomegaly, total count of 1,20,000 cells/mm³ and peripheral smear showed predominance of myeloid precursors. What is your diagnosis? Draw diagram of peripheral smear. What is the common genetic event in this condition?")] }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q8(A): ", bold: true }), new TextRun("Two characteristic differences between myeloblasts and lymphoblasts.")] }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q8(D): ", bold: true }), new TextRun("What is eosinophilia? Enumerate two clinical conditions with eosinophilia.")] }), new Paragraph({ children: [new TextRun({ text: "Paper II - Q8(C): ", bold: true }), new TextRun("Name a diagnostic test in urine in multiple myeloma.")] }), new Paragraph({ text: "" }), // ============================================================ // SECTION 11: CLINICAL PATHOLOGY (LAB MEDICINE) // ============================================================ new Paragraph({ text: "11. CLINICAL PATHOLOGY / LABORATORY MEDICINE", heading: HeadingLevel.HEADING_1 }), // 11.1 Haematology Lab new Paragraph({ text: "11.1 Transfusion Medicine", heading: HeadingLevel.HEADING_2 }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q5 (Long Essay): ", bold: true }), new TextRun("Define adverse transfusion reaction. Write classification and explain the pathogenesis of it.")] }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q6(D): ", bold: true }), new TextRun("Haemolytic disease of the newborn (HDN).")] }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q8(A): ", bold: true }), new TextRun("Enumerate the indications of platelet concentrate transfusion.")] }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q8(B): ", bold: true }), new TextRun("Direct Antiglobulin Test (DAT).")] }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q8(F): ", bold: true }), new TextRun("\"Sodium heparin is an anticoagulant of choice for the Fibrinogen level test\" - Sentence is true or false?")] }), new Paragraph({ text: "" }), // 11.2 Biochemistry & Endocrine Tests new Paragraph({ text: "11.2 Biochemistry / Endocrine Function Tests", heading: HeadingLevel.HEADING_2 }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q6(A): ", bold: true }), new TextRun("Thyroid function tests.")] }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q6(B): ", bold: true }), new TextRun("Enumerate WHO criteria for Normal semen analysis.")] }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q6(C): ", bold: true }), new TextRun("What is Activated Partial Thromboplastin Time (APTT)? What is the principle and normal value of APTT? Enumerate 2 conditions where it can increase with significance.")] }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q8(C): ", bold: true }), new TextRun("What is the difference between fructosamine level test and Glucose Tolerance Test?")] }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q8(E): ", bold: true }), new TextRun("What is ketonuria and its significance?")] }), new Paragraph({ text: "" }), // 11.3 Renal & Liver Function Tests new Paragraph({ text: "11.3 Renal & Liver Function Tests", heading: HeadingLevel.HEADING_2 }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q7(A): ", bold: true }), new TextRun("Describe Renal Function tests.")] }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q7(B): ", bold: true }), new TextRun("What are the changes you expect in liver function test (LFT) in case of a patient infected with Hepatitis A virus?")] }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q7(C): ", bold: true }), new TextRun("Urinary crystals.")] }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q7(D): ", bold: true }), new TextRun("Write differences of CSF analysis in case of bacterial meningitis and tuberculous meningitis.")] }), new Paragraph({ children: [new TextRun({ text: "Paper I - Q8(D): ", bold: true }), new TextRun("What is opportunistic infection and give example of it.")] }), new Paragraph({ text: "" }), // ============================================================ // NOTE // ============================================================ new Paragraph({ text: "NOTES", heading: HeadingLevel.HEADING_1 }), new Paragraph({ children: [new TextRun({ text: "Note: Only the 'prelims paper (1).pdf' contained Pathology subject questions (Shantabaa Medical College, Amreli). The remaining four PDFs (PDU Prelims 2025, 2nd Year Uni Exam Feb 2024, University 2nd Year 2024) are Pharmacology papers. The '22 Batch Prelims 2nd Year' PDF was not readable (scanned images with no extractable text).", italics: true, size: 20 })] }), ] }] }); Packer.toBuffer(doc).then(buffer => { fs.writeFileSync("/home/daytona/workspace/pathology-questions/Pathology_Questions_By_System.docx", buffer); console.log("DOCX created successfully."); }).catch(err => { console.error("Error:", err); }); JSEOF cd /home/daytona/workspace/pathology-questions && node create_doc.js
python3 /home/daytona/skills/docx/scripts/office/validate.py /home/daytona/workspace/pathology-questions/Pathology_Questions_By_System.docx 2>&1 | head -20
ls -lh /home/daytona/workspace/pathology-questions/Pathology_Questions_By_System.docx && python3 -c " from zipfile import ZipFile with ZipFile('/home/daytona/workspace/pathology-questions/Pathology_Questions_By_System.docx') as z: print('Files in DOCX:', z.namelist()[:5]) print('DOCX opens OK') "
Pathology Questions By System
Word Document · DOCX