Loads a PDF file using the pdf-reader gem, producing one document per page. Each document's metadata includes the page number.
#lazy_load
9 10 11 12 13 14 15 16 17
# File 'lib/ask/rag/loader/pdf.rb', line 9 def load(path) reader = PDF::Reader.new(path) reader.pages.map.with_index(1) do |page, idx| Ask::Document.new( content: page.text, metadata: { source: path, page: idx, format: "pdf" } ) end end