Download scripts/text_extract_test.py from lakresi/ragify: direct link, hf CLI and curl.
- Browser
- Download file 446 Bytes
-
https://huggingface.co/spaces/lakresi/ragify/resolve/main/scripts/text_extract_test.py
- Command line
-
hf download hf://spaces/lakresi/ragify/scripts/text_extract_test.py
-
curl -L -o text_extract_test.py https://huggingface.co/spaces/lakresi/ragify/resolve/main/scripts/text_extract_test.py
446 Bytes
| 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 | |