Back to portfolio

Search across 30 Polish textbooks

Find exercises by topic and open the exact page in the original book.

Python, vision models, semantic searchIndependent project for a Polish teacher
Problem
Preparing one 60-minute Polish lesson meant opening a dozen 200-page PDFs one by one just to find five drills on the same grammar case.
My role
I designed and built the vision extraction pipeline, deterministic Python verifier, hybrid search engine, and page reader for one teacher. Textbook content belongs to its publishers.
Solution
Vision-assisted task detection backed by strict Python invariants, semantic + lexical ranking, and a split-pane reader anchored to the original book and page.
Outcome
By September 2026, the library indexed 30 textbooks with 5,973 verified exercises ready to assign across 29 of them.

My girlfriend started teaching Polish on Preply. She had around 30 textbooks and workbooks covering A1 through C1, packed with great exercises. The catch? Preparing a single 60-minute lesson on the genitive plural meant opening a dozen 200-page PDFs one by one and scrolling until her eyes hurt.

  • Cover of Bądź na B1
  • Cover of Polski krok po kroku junior 1
  • Cover of Gramatyka? Dlaczego nie?!
  • Cover of Polski na dobry start - podręcznik A1
  • Cover of A to polski właśnie! - część 1
  • Cover of Z językiem polskim każdego dnia - A2-B1
A selection of the 30 books - covers by their publishers.

So I built a library around one rule: search the exercise, not the book. Type a grammar topic, pick a level, and compare drills from different publishers side by side, with the original book and page number attached to every single crop.

Why standard OCR makes a mess of language workbooks

A language textbook page is not a novel. It is a collage of two-column drills, fill-in-the-blank tables, dialogue bubbles, crossword grids, and answer keys. Run plain text OCR and you destroy the visual layout that makes an exercise usable in class. Run naive object detection and a 10-line drill gets chopped into 10 orphan sentences without their instruction.

Instead, a vision model first decides whether a page contains learner tasks at all (skipping covers, tables of contents, and transcripts). Then it draws bounding boxes that keep each governing instruction glued to all ten of its numbered lines.

One page, four exercises
Original HURRA page with four saved exercise regions outlined: full-width tasks 6 and 7, then side-by-side tasks 8 and 9. All answer items remain within their parent task.
Four tasks, not every numbered line.
Instructions and answer spaces stay together.
HURRA, p. 116 - artwork by the publisher.

The model proposes; the code checks. Python clamps every bounding box so a neighbouring column cannot bleed into the crop, drops duplicate detections, and throws out boxes that captured only a section heading.

When an exercise spills onto the next page

Textbooks love putting a reading passage at the bottom of page 60 and the questions at the top of page 61. My cross-page reconciler compares unfinished fragments on consecutive pages by numbering, column position, and wording, joining only the pairs that actually belong together.

If an instruction is still missing its body, the pipeline re-examines both pages together as a spread. Anything that still looks incomplete is quarantined from search. A teacher prepping ten minutes before class should never be handed half a drill.

For incomplete tasks, compare fragments on consecutive pages. Join compatible fragments. If a continuation is missing, recheck the page pair; unresolved fragments stay hidden from search.
Cross-page reconciliation: match compatible fragments, re-check page pairs, and hide anything still unfinished.

Some magazine-style spreads still beat automation. In this football exercise, the instruction sits above one column while the stadium illustration stretches across the gutter of both pages. For cases like that, I built a manual repair tool: pick three regions across the spread, keep their original scale, and stitch them into one clean task.

PDF page 60PDF page 61
Two original Krok po kroku junior pages, with the football task’s instruction marked A and the two parts of its illustration marked B and C
A is the instruction. B and C are the scene it refers to.Polski krok po kroku junior 1, pp. 70-71 - artwork by the publisher.
Saved, manually reviewed football exercise assembled from three regions on two textbook pages
One task, manually repaired.

Rank twelve, pick four, check every ID

When the teacher wants a full 45-minute lesson draft, the backend ranks verified exercises by CEFR level, Polish keyword matches, and embedding similarity, then hands the top 12 candidates to the model to sequence two to five tasks from warm-up to practice.

Here too, the server has the last word: FastAPI verifies every returned exercise ID against SQLite, strips duplicates, and checks that the minutes add up. If the model times out or invents an ID, a deterministic fallback builds the lesson directly from the ranked shortlist.

Topic, level and goal rank up to 12 complete tasks. AI arranges a lesson from that shortlist. The server validates exercise IDs, removes duplicates and fits the time. A local plan is available as a fallback.
Rank up to 12 verified tasks, sequence with the model, and enforce ID and time-budget rules in Python.

Back to the classroom

Day to day, the read-only search view does most of the heavy lifting: type a topic, filter by level, and open the exercise right next to its full original textbook page so the teacher can check surrounding grammar notes in one click.

The original Polish exercise open in the read-only viewer
Exercise 7 open in the split-pane reader, with its source book and page.

In September 2026 the library held 30 books, with 5,973 exercises marked complete from 29 of them. That is an operational snapshot, not a vanity score: levels and topic tags are estimates, and wild page layouts still need a human eye. What changed is simpler: lesson prep now starts with a two-second search instead of a pile of 30 PDFs.

Design & development
Vasyl Narbut
Built with
Python, FastAPI, SQLite, a vision model, embeddings, Next.js
Textbook material
The respective publishers