Skip to content

feat(document): draw the document as paper, and say which page every excerpt is on (E13-T12) - #108

Merged
danielgorgonha merged 1 commit into
mainfrom
feat/document-as-paper
Sep 21, 2026
Merged

danielgorgonha merged 1 commit into
mainfrom
feat/document-as-paper

Conversation

@danielgorgonha

Copy link
Copy Markdown
Member

Sexta fatia do E13 (#23).

O problema

O produto diz "isto está no seu documento" e a pessoa olha para o papel na mão dela. No papel há páginas numeradas; na tela havia um bloco de vinte e cinco mil caracteres e nenhuma forma de ligar um ao outro.

Afirmação cara demais de conferir não é conferível na prática: num agravo de catorze folhas, achar uma frase custa varrer as catorze.

O dado já existia

O extrator escreve ===== PÁGINA n ===== entre as folhas desde sempre, em core/pdf_extract.py, e nada usava. Agora o MarkedText desenha cada página como folha com "Página 3 de 14", e todo trecho diz em que página está: os tópicos da jornada e os itens marcados na revisão do advogado.

Onde a página é calculada importa

No serviço, não na tela. A página é fato do documento e o documento está daquele lado; calcular na jornada exigiria mandar o texto extraído inteiro para uma tela que só precisa de um rótulo.

O lib/pages.ts continua existindo e testado, porque separar em folhas para desenhá-las é trabalho diferente de atribuir uma posição, e o lado que desenha genuinamente tem o texto.

Documento sem separador recebe null, nunca "página 1"

Inventar o número fabricaria exatamente o dado que isto existe para trazer. E documento antigo, extraído antes de o separador existir, é justamente o caso que receberia uma resposta errada com cara de certa.

Dois detalhes que a marcação exigiu

Item que atravessa a virada de página fica na folha onde começa. Recortá-lo em dois daria à pessoa duas marcações para um trecho.

O texto da folha é a fatia crua, nunca aparada. As marcações são desenhadas contra as posições do documento, e aparar deslocaria toda marcação daquela folha.

Medido no agravo real de 14 páginas

40 itens marcados, distribuídos pelas páginas 1, 2, 3, 4, 6, 8, 11, 12 e 14. Os cinco tópicos publicados caem todos na página 1, o que está certo para uma peça recursal: a abertura carrega as partes e o que está sendo pedido.

210 testes no serviço, 96 no aplicativo, lint e build limpos.

…excerpt is on

E13-T12. The product says "this is in your document" and the person looks at the paper in her hand. On
paper there are numbered pages; on screen there was a single block of twenty-five thousand characters and
no way to tie one to the other.

The extractor has been writing ===== PÁGINA n ===== between sheets all along, in core/pdf_extract.py, and
nothing used it. MarkedText now draws each page as a sheet with "Página 3 de 14", and every excerpt says
which page it is on: the topics in the journey, the marked items in the lawyer's review.

Where the page is computed matters. It belongs to the service, not the screen, because the page is a fact
about the document and the document is on that side; computing it in the journey would mean shipping the
whole extracted text to a screen that only needs a label. lib/pages.ts still exists and is still tested,
because splitting into sheets to draw them is a different job from attributing one position, and the
drawing side genuinely has the text.

A document with no separator gets null, never "page 1". Inventing the number would fabricate exactly the
datum this is here to carry, and an older document extracted before the separator existed is precisely the
case that would get a confident wrong answer.

Two details the marks needed. An item crossing a page break stays on the sheet where it starts, because
cutting it in two would give the person two marks for one excerpt. And the sheet's text is the raw slice,
never trimmed: the marks are drawn against document positions, and trimming would shift every mark on that
sheet.

Measured on the real 14-page agravo: 40 marked items spread across pages 1, 2, 3, 4, 6, 8, 11, 12 and 14.
The five published topics all land on page 1, which is right for a recursal piece, whose opening carries
the parties and what is being asked.
@vercel

vercel Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
leia Ready Ready Preview Sep 21, 2026 2:25pm UTC

Request Review

@danielgorgonha
danielgorgonha merged commit 495d0e4 into main Sep 21, 2026
4 checks passed
@danielgorgonha
danielgorgonha deleted the feat/document-as-paper branch September 21, 2026 14:43

This branch was successfully deployed

1 active deployment
Preview — 5b3a67c8 Deployed Sep 21, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant