#################################### PRGname = 'Resumation' PRGvers = '0.2' #impl better parsing #################################### #imports from reportlab.pdfgen import canvas from reportlab.lib.pagesizes import letter from reportlab.lib.styles import getSampleStyleSheet from reportlab.lib.units import inch from reportlab.lib import colors from reportlab.platypus import Paragraph, Frame, Table, TableStyle ##defs def ripple(item, depth): #max spread 5; depth 0-indexed while(depth<5): scan = ctree[item] #takes string returns children for i in scan: points[scan[i][0]] =+ 5-depth for i in scan: ripple(scan[i], depth+1) #passes string def addval(todict, ikey, ival): #helper for list addition key = ikey.rstrip('\n') val = ival.rstrip('\n') if key in todict: todict[key].append(val) if key not in todict: todict[key] = [] todict[key].append(val) def linemap(line): if line in linemapping: return linemapping[line] else: return line ##User contents (sort from file later) Uname = 'Owen Gruebmeyer-Mulqueen' Umail = 'ogruebmeyermulqueen@regis.edu' Uaddr = '############################' Uphon = '720-403-0255' Uwebs = 'opusculum.net' Uothr = '' Ubio = 'Outgoing student seeking entry-level position\ to develop applied and workplace skills for further advancement in Software Engineering' #skills; list of applicable strings in no order praxia = {''} #section: education/employment(e). format: (current,position,org,dates) secEi1 = (2,'B.A. Student in Computer Science','Regis University College of Computer and Information Sciences','2015-2020') secEi2 = (0,'Graduate','East High School','June 2014') #section: extracurricular(v) secVi1 = (0,'Volunteer','Wild B.I.R.D.','2010-2017') secVi2 = (1,'Member','Denver Field Ornithologists','2016-2020') #section: profile(c); special formatting cogprof = dict() cogprof['Verbal comprehension'] = 141 cogprof['Perceptual reasoning'] = 127 cogprof['Working memory'] = 108 cogprof['Processing speed'] = 89 cofprof['General ability'] = 139 data = [list(cogprof),list(cogprof.values())] #for table generation ## ##Scoring framework ##Category definitions/inheritance #ctree parser from file textc = open('ctree.txt','r') text = textc.readlines() ctree = dict() depth = 0 ptiers = dict() #depth key, parent value for l in range(len(text)): if (text[l][0]!='-'): #outermost parent depth = 0 ptiers[depth] = text[l][depth:] elif (text[l][depth]!='-')and(text[l][depth-1]!='-'): #< for m in range(depth): #break back syntax if (text[l][m]!='-'): depth = m break ptiers[depth] = text[l][depth:] addval(ctree, ptiers[depth-1], ptiers[depth]) elif (text[l][depth]!='-')and(text[l][depth-1]=='-'): #V ptiers[depth] = text[l][depth:] addval(ctree, ptiers[depth-1], ptiers[depth]) elif (text[l][depth]=='-'): #> depth += 1 ptiers[depth] = text[l][depth:] addval(ctree, ptiers[depth-1], ptiers[depth]) textc.close() #parses ctree for parent lists parentlist = list(ctree.keys()) ptree = dict() for i in parentlist: parent = i children = ctree[parent] for j in children: ptree[j] = parent #established dict for all scorables points = dict.fromkeys(ptree.keys(),0) ##Input parsing; SINGLE FILE (hard-coded sections) texti = open('posting.txt','r') text = texti.readlines() texti.close() Ptitl = text[0] Pcont = text[1] Porgn = text[2] Pmail = text[3] ##Scoring/selection alg; NEEDS SOLUTION FOR CASE-INSENSITIVE COMPARES allwords = Pcont.split() trimwords = allwords #use re module to trim, or? for i in trimwords: if trimwords[i] in points: #check word can be scored ripple(trimwords[i], 0) #scores word from depth 0; RECURSIVE #ONLY CHECKS CHILDREN; NO DEFAULT TO GENERAL KNOWLEDGE ptotal = sum(points.values()) #scores any applicable skills by points score = dict.fromkeys(praxia, 0) for j in praxia: if praxia[j] in points: score[praxia[j]] = points[praxia[j]] stotal = sum(score.values()) #checks score out of possible print("Total points possible: "+str(ptotal)) print("Total score: "+str(stotal)) print("Possible fraction: "+str(round(stotal/ptotal,3))) print("Scaled fraction: "+str(round(stotal*5/ptotal,3))) if (stotal*5/ptotal)<0.5: print("WARNING: low score, suggested not for submission!") #consider adding watermark # selects = sorted(score, key=score.get) selects[:10] #picks top 10 items ##prepare for print #establish template #add obligatory header #retrieve lines for selected items #format selected items #add obligatory footer # ##clear points pkeys = list(points) for i in pkeys: points[pkeys[i]]=0 ##export canv.save()