Resume_Analyzer / backend /src /loader.py
SarthakVE's picture
Upload folder using huggingface_hub
f68cb35 verified
Raw History Blame Contribute Delete
990 Bytes
from langchain_community.document_loaders import PyMuPDFLoader, TextLoader, Docx2txtLoader
from pathlib import Path
def load_JD(file_path):
loader = TextLoader(file_path, encoding="utf-8")
documents = loader.load()
return documents
# def load_resume(file_path):
# loader = PyMuPDFLoader(file_path)
# documents = loader.load()
# return documents
def load_resume(file_path):
extension=Path(file_path).suffix.lower()
if extension==".pdf":
loader=PyMuPDFLoader(file_path)
elif extension==".docx":
loader=Docx2txtLoader(file_path)
else:
raise ValueError(f"Unsupported resume format: {extension}. Supported are .pdf and .docx only.")
return loader.load()
# # Loop through all pages and print their text content
# for doc in documents:
# print(doc.page_content)
# print("-" * 50) # Just a separator line between pages
# return documents