APPENDIX BCode for screen.py

This appendix displays the code blocks as described and discussed in Chapter 4, “Computational Thinking in Practice.” Each code block is labeled alphabetically for more convenient reference.

A

# screen.py
 
# Like in the app.py code, software modules are loaded in to help set up the
# software environment.
# No need to duplicate the code here!
 
# creates the ResultElement object, containing rank value and filename
class ResultElement:
    def __init__(self, rank, filename):
        self.rank = rank
        self.filename = filename
 
# function: access and return the filepath reformatted using forward slashes
def getfilepath(loc):
    temp = str(loc)
    temp = temp.replace('\\', '/')
    return temp
 
# function: recursively retrieves resume documents that are formatted as 
# pdf, doc and docx. Each page of resume is captured separately and text
# extracted using extractText() for pdfs or textract.process() for MS Word
def res(jobfile):
    # create empty vectors to store files of different formats, text
    # from resumes, etc
    Resume_Vector = []
    Ordered_list_Resume = []
    Ordered_list_Resume_Score = []
    LIST_OF_FILES = []
    LIST_OF_FILES_PDF = []
    LIST_OF_FILES_DOC = []
    LIST_OF_FILES_DOCX = []
    Resumes = [] 
    Temp_pdf = []
 
    # iterate through the resumes directory, separately listing them
    # into vectors
    os.chdir('./Original_Resumes')
    for file in glob.glob('**/*.pdf', recursive=True):
        LIST_OF_FILES_PDF.append(file)
    for file in glob.glob('**/*.doc', recursive=True):

Get Data Conscience now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.