Spaces:
Sleeping
Sleeping
File size: 1,394 Bytes
46917c3 |
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 38 39 40 41 42 43 44 |
import json
import os.path
import pathlib
from .parsers import ParseJobDesc, ParseResume
from .ReadPdf import read_single_pdf
READ_RESUME_FROM = "Data/Resumes/"
SAVE_DIRECTORY = "Data/Processed/Resumes"
class ResumeProcessor:
def __init__(self, input_file):
self.input_file = input_file
self.input_file_name = os.path.join(READ_RESUME_FROM + self.input_file)
def process(self) -> bool:
try:
resume_dict = self._read_resumes()
self._write_json_file(resume_dict)
return True
except Exception as e:
print(f"An error occurred: {str(e)}")
return False
def _read_resumes(self) -> dict:
data = read_single_pdf(self.input_file_name)
output = ParseResume(data).get_JSON()
return output
def _read_job_desc(self) -> dict:
data = read_single_pdf(self.input_file_name)
output = ParseJobDesc(data).get_JSON()
return output
def _write_json_file(self, resume_dictionary: dict):
file_name = str(
"Resume-" + self.input_file + resume_dictionary["unique_id"] + ".json"
)
save_directory_name = pathlib.Path(SAVE_DIRECTORY) / file_name
json_object = json.dumps(resume_dictionary, sort_keys=True, indent=14)
with open(save_directory_name, "w+") as outfile:
outfile.write(json_object)
|