-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #372 from VikParuchuri/vik_v2
Vik v2
- Loading branch information
Showing
18 changed files
with
205 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from marker.v2.processors import BaseProcessor | ||
from marker.v2.schema import BlockTypes | ||
from marker.v2.schema.document import Document | ||
|
||
|
||
class DocumentTOCProcessor(BaseProcessor): | ||
block_types = (BlockTypes.SectionHeader, ) | ||
|
||
def __call__(self, document: Document): | ||
toc = [] | ||
for page in document.pages: | ||
for block in page.children: | ||
if block.block_type not in self.block_types: | ||
continue | ||
|
||
toc.append({ | ||
"title": block.raw_text(document).strip(), | ||
"heading_level": block.heading_level, | ||
"page_id": page.page_id, | ||
"polygon": block.polygon.polygon | ||
}) | ||
document.table_of_contents = toc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.