Analyze these previous year question papers. Create a Topic Frequency Matrix showing how many times each major topic appeared. Based on this, predict the top most important topics for the upcoming exam and justify your answer based on weightage and trend analysis
cd /tmp/workspace/attachments/bd9fc7ae-ff0d-433d-b67c-1aaf81ddb46a && python3 -c " import pdfplumber with pdfplumber.open('biomechanics-1.pdf') as pdf: print(f'Total pages: {len(pdf.pages)}') for i, page in enumerate(pdf.pages): text = page.extract_text() print(f'\n===== PAGE {i+1} =====') print(text) " 2>&1 | head -500
python3 -c " from pypdf import PdfReader reader = PdfReader('/tmp/workspace/attachments/bd9fc7ae-ff0d-433d-b67c-1aaf81ddb46a/biomechanics-1.pdf') print(f'Pages: {len(reader.pages)}') for i, page in enumerate(reader.pages): text = page.extract_text() print(f'\n=== PAGE {i+1} ===') print(repr(text[:500]) if text else '[EMPTY]') "
python3 -c " from pypdf import PdfReader, PdfWriter import os reader = PdfReader('/tmp/workspace/attachments/bd9fc7ae-ff0d-433d-b67c-1aaf81ddb46a/biomechanics-1.pdf') print('Num pages:', len(reader.pages)) # Try to extract images from each page for i, page in enumerate(reader.pages): images = page.images print(f'Page {i+1}: {len(images)} images') for j, img in enumerate(images): name = f'/tmp/workspace/bio_page{i+1}_img{j+1}.{img.name.split(\".\")[-1]}' with open(name, 'wb') as f: f.write(img.data) print(f' Saved: {name} ({len(img.data)} bytes)') "
cd /tmp/workspace && python3 -m http.server 8765 &>/tmp/http_server.log & sleep 1 echo "Server started, PID: $!" curl -s -o /dev/null -w "%{http_code}" http://localhost:8765/bio_page1_img1.jpg
python3 -c " import pytesseract from PIL import Image pages_text = {} for i in range(1, 9): try: img = Image.open(f'/tmp/workspace/bio_page{i}_img1.jpg') text = pytesseract.image_to_string(img) pages_text[i] = text print(f'=== PAGE {i} ===') print(text[:2000]) print() except Exception as e: print(f'Page {i} error: {e}') " 2>&1
pip install --user pytesseract 2>&1 | tail -3 && python3 -c "import pytesseract; print('ok')"
python3 -c " import pytesseract from PIL import Image for i in range(1, 9): try: img = Image.open(f'/tmp/workspace/bio_page{i}_img1.jpg') text = pytesseract.image_to_string(img) print(f'=== PAGE {i} ===') print(text) print() except Exception as e: print(f'Page {i} error: {e}') " 2>&1
# Try to use easyocr or markitdown to extract text from the PDF python3 -c "from markitdown import MarkItDown; md = MarkItDown(); result = md.convert('/tmp/workspace/attachments/bd9fc7ae-ff0d-433d-b67c-1aaf81ddb46a/biomechanics-1.pdf'); print(result.text_content[:5000])" 2>&1
# Try easyocr python3 -c " import easyocr reader = easyocr.Reader(['en'], gpu=False) result = reader.readtext('/tmp/workspace/bio_page1_img1.jpg', detail=0, paragraph=True) print('\n'.join(result)) " 2>&1 | head -100
# Let's try using the vision model through base64-encoded images in the PDF reader # First, let me check what image metadata looks like and try to get the images as base64 for direct viewing python3 -c " from PIL import Image import base64, io # Check image dimensions and quality for i in range(1, 9): img = Image.open(f'/tmp/workspace/bio_page{i}_img1.jpg') print(f'Page {i}: {img.size} mode={img.mode}') "
# Use PIL to enhance contrast and try to get readable text using CV2/numpy-based approach # Also let's try to use the file:// URL directly python3 -c " import base64 # Convert images to base64 and save as data URIs for potential use with open('/tmp/workspace/bio_page1_img1.jpg', 'rb') as f: data = f.read() print(f'Image size: {len(data)} bytes') # Check if image is readable from PIL import Image img = Image.open('/tmp/workspace/bio_page1_img1.jpg') # Crop to top portion to see the header top = img.crop((0, 0, 1600, 800)) top.save('/tmp/workspace/bio_page1_top.jpg', quality=95) bottom = img.crop((0, 800, 1600, 2560)) bottom.save('/tmp/workspace/bio_page1_bottom.jpg', quality=95) print('Saved cropped images') "