File size: 446 Bytes
2c69fef 86f9adc 2c69fef 86f9adc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import pdfplumber as pp
import os
from dotenv import load_dotenv
import chromadb
client = chromadb.Client()
collection = client.create_collection(name="doc_collection")
load_dotenv()
ENV = os.getenv("ENV", "local")
corpus_path = "../corpus/d2l-en.pdf"
with pp.open(corpus_path) as f:
for page in f.pages:
collection.add(
ids = [str(page.page_number)],
documents=[page.extract_text()]
)
break
|