hello-yaaash25's picture
Initial commit without binary files
29c4d1d
Raw History Blame Contribute Delete
984 Bytes
from typing import List
import os
class DocumentLoader:
def __init__(self, file_paths: List[str]):
self.file_paths = file_paths
def load_documents(self) -> List[str]:
documents = []
for file_path in self.file_paths:
if os.path.exists(file_path):
with open(file_path, 'r', encoding='utf-8') as file:
documents.append(file.read())
else:
raise FileNotFoundError(f"File not found: {file_path}")
return documents
def load_from_directory(self, directory_path: str) -> List[str]:
documents = []
for filename in os.listdir(directory_path):
file_path = os.path.join(directory_path, filename)
if os.path.isfile(file_path):
documents.extend(self.load_documents([file_path]))
return documents
def load_pdf(self, pdf_path: str) -> str:
raise NotImplementedError("PDF loading not implemented yet.")