【发布时间】:2021-08-20 09:30:41
【问题描述】:
这是一个基于简历筛选的程序。在这个程序中,我为每个 CV 打分以对它们进行排名。现在输出只是给了我我想要的分数,它给了我文件名。 程序是:
import re
import fitz
import os
# Create an array "zs[]" that store the score values
zs = []
# call the Resume files by calling the folder name
for filename in os.listdir('resume/'):
# Select only PDF files
if filename.endswith('.pdf'):
print(filename)
os.chdir('C:/Users/M. Abrar Hussain/Desktop/cv/resume')
pdfFileObj = open(filename, 'rb')
# Extract the text Data from resume files
with fitz.open(pdfFileObj) as doc:
text = ""
for page in doc:
text += page.getText()
print(text)
# Splitting the Resume Data into many indexes of Array
p = doc.loadPage(0)
p_text = p.getText()
p_lines = p_text.splitlines()
# Split the information and the data
split_lst = [i.split(': ', 1) for i in p_lines]
d = {a: b.rstrip() for a, b in split_lst}
# Naming the information part
f = d["Name"]
g = d["GPA"]
h = d["Skills"]
i = d["Experience"]
p = re.findall(r"[-+]?\d*\.\d+|\d+", i)
# search the keywords with the data that extract from resume
search_keywords = ['Laravel', 'Java', 'Python']
search_exp = ['1', '1.5', '2', '2.5', '3']
search_gpa = ['2.5', '2.6', '2.7', '2.8', '2.9', '3.0', '3.1', '3.2', '3.3', '3.4', '3.5', '3.6', '3.7',
'3.8', '3.9', '4.0']
# Comparing GPA data with the keywords
lst = []
for gpa in search_gpa:
if gpa in g:
lst.append(gpa)
# Comparing Skills data with keywords
lst1 = []
for word in search_keywords:
if word in h:
lst1.append(word)
# Comparing Experience data with keywords
lst2 = []
for exp in search_exp:
if exp in p:
lst2.append(exp)
# Scoring the Extracted data to see the best resume
score = 0
w1 = []
# Scoring the GPA
for w1 in lst:
if '3.0' <= w1 < '3.5':
score += 1
if '3.5' <= w1 <= '4':
score += 2
# Scoring the SKills
for w1 in lst1:
if w1 == 'Laravel':
score += 2
if w1 == 'Python':
score += 2
if w1 == 'Java':
score += 1
# Scoring the Experience
for w1 in lst2:
if '2.5' <= w1 < '3':
score += 0.5
if '3' <= w1 < '3.5':
score += 1
if '3.5' <= w1:
score += 2
# store score values in an array
tt = zs.append(score)
print("%s has Scored %s" % (f, score))
print('\n')
pdfFileObj.close()
# Rank the CV's on the basis of Scoring
zs.sort(reverse=True)
print(zs)
程序的输出是:
cv2.pdf
Name: Danish Ejaz
GPA: 3.7
Skills: Python, Java
Experience: 2.5 years
Danish Ejaz has Scored 5.5
cv3.pdf
Name: Abdullah
GPA: 3.2
Skills: Laravel, Java
Experience: 2 years
Abdullah has Scored 4
cv5.pdf
Name: M. Abrar Hussain
GPA: 3.5
Skills: Python, Laravel
Experience: 3 years
M. Abrar Hussain has Scored 7
[7, 5.5, 4]
Process finished with exit code 0
倒数第二行是计分后的结果。在这个结果中,它只给了我们得分号,我也可以在结果中调用文件名吗?如果是,请帮助我完成这个项目。
【问题讨论】:
-
您想在某些查看器中打开最好的 pdf 文件吗?
-
你能发布你期望的输出吗?
-
@RomanPavelka 是的,评分基于经验、技能和 GPA。
-
@ignoring_gravity [7, 5.5, 4] 这是程序的输出,我想要这样的文件名 [7 cv5.pdf, 5.5 cv2.pdf, 4 cv3.pdf]