Spaces:
Sleeping
Sleeping
Download modules/pdf_utils.py from renannoronha/PersonAI: direct link, hf CLI and curl.
- Browser
- Download file 404 Bytes
-
https://huggingface.co/spaces/renannoronha/PersonAI/resolve/main/modules/pdf_utils.py
- Command line
-
hf download hf://spaces/renannoronha/PersonAI/modules/pdf_utils.py
-
curl -L -o pdf_utils.py https://huggingface.co/spaces/renannoronha/PersonAI/resolve/main/modules/pdf_utils.py
404 Bytes
| import fitz | |
| def extract_text_from_pdf(file_path): | |
| doc = fitz.open(file_path) | |
| text = "" | |
| for page in doc: | |
| text += page.get_text() | |
| return text | |
| def chunk_text(text, chunk_size=500, overlap=100): | |
| chunks = [] | |
| start = 0 | |
| while start < len(text): | |
| end = start + chunk_size | |
| chunks.append(text[start:end]) | |
| start += chunk_size - overlap | |
| return chunks | |