File size: 990 Bytes
a47acf9
 
 
dc7b3f0
 
 
 
 
 
a47acf9
 
 
 
 
dc7b3f0
a47acf9
 
 
 
 
 
 
 
 
 
 
 
f68cb35
 
 
 
 
 
 
dc7b3f0
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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