Download Parser.py from Mr-Thop/Axion: direct link, hf CLI and curl.
- Browser
- Download file 507 Bytes
-
https://huggingface.co/spaces/Mr-Thop/Axion/resolve/main/Parser.py
- Command line
-
hf download hf://spaces/Mr-Thop/Axion/Parser.py
-
curl -L -o Parser.py https://huggingface.co/spaces/Mr-Thop/Axion/resolve/main/Parser.py
507 Bytes
| from langchain_community.document_loaders import PyPDFLoader | |
| class Parser(): | |
| def __init__(self): | |
| pass | |
| def parse(self,file_path): | |
| loader = PyPDFLoader(file_path) | |
| pages = loader.load_and_split() | |
| no_of_pages = pages[0].metadata["total_pages"] | |
| content = [] | |
| for i in range(no_of_pages): | |
| content.append(pages[i].page_content) | |
| return { | |
| "content": content, | |
| "no_of_pages": no_of_pages | |
| } | |