You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I searched existing ideas and did not find a similar one
I added a very descriptive title
I've clearly described the feature request and motivation for it
Feature request
The idea ist to split a PDF or WORD file based on the bookmarks of the files. The chunk size must be set dynamicy based on an index function or the like. This way each chunk would contain the chapter context only and no overlap would be needed.
I tested to extract bookmarks from PDFs and it works with a function like this one:
import PyPDF2
pdf_path = "PATH OF THE PDF FILE"
def get_bookmarks_from_pdf(pdf_path):
with open(pdf_path, 'rb') as file:
reader = PyPDF2.PdfReader(file)
bookmarks = []
def _get_bookmarks(outline_items):
for item in outline_items:
if isinstance(item, list):
# Recursive call for nested bookmarks
_get_bookmarks(item)
elif isinstance(item, PyPDF2.generic.Destination):
bookmarks.append(item['/Title'])
if reader.outlines:
_get_bookmarks(reader.outlines)
return bookmarks
bookmarks = get_bookmarks_from_pdf(pdf_path)
Motivation
I didnt find a document splitter from langchain that works with bookmarks and fills the chunks with the chapter context.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked
Feature request
The idea ist to split a PDF or WORD file based on the bookmarks of the files. The chunk size must be set dynamicy based on an index function or the like. This way each chunk would contain the chapter context only and no overlap would be needed.
I tested to extract bookmarks from PDFs and it works with a function like this one:
import PyPDF2
pdf_path = "PATH OF THE PDF FILE"
def get_bookmarks_from_pdf(pdf_path):
with open(pdf_path, 'rb') as file:
reader = PyPDF2.PdfReader(file)
bookmarks = []
def _get_bookmarks(outline_items):
for item in outline_items:
if isinstance(item, list):
# Recursive call for nested bookmarks
_get_bookmarks(item)
elif isinstance(item, PyPDF2.generic.Destination):
bookmarks.append(item['/Title'])
if reader.outlines:
_get_bookmarks(reader.outlines)
return bookmarks
bookmarks = get_bookmarks_from_pdf(pdf_path)
Motivation
I didnt find a document splitter from langchain that works with bookmarks and fills the chunks with the chapter context.
Proposal (If applicable)
No response
Beta Was this translation helpful? Give feedback.
All reactions