[Python] Algorithm that finds chapter titles in file [closed]

Discussão em 'Python' iniciado por Stack, Março 29, 2025.

  1. Stack

    Stack Membro Participativo

    I am struggling with finding algorithm that would print title of chapters, may be together with chapter numbers. I have big pdf file converted to text and i need to pick chapter numbers from that big text.

    1 Introduction
    1.1 Background
    1.1.1 Subsection A
    3.5 awert this is not a chapter because it is not in hierarchy (there is no chapter 2 and 3)
    24.02.2025 This is not a chapter
    2 Methodology
    1.1.2 Subsection B
    1.2 Another Section
    1.1.1.1 A deeper subchapter
    1.2.1 Another subchapter


    I dont know if it could be a regex expression, partially maybe yes, but it should not treat similar numbers present in text as chapters, unless they are the same as real chapters. To be sure that chapter is real, propalby there should be some tree build from that numbers to check if they are ordered so that chapter 50.1 would not be be found because, i tried different approaches with regex but with no luck.

    Result should be

    Continue reading...

Compartilhe esta Página