forked from srbhr/Resume-Matcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fileReader.py
72 lines (52 loc) · 1.96 KB
/
fileReader.py
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
from operator import index
from pandas._config.config import options
import Cleaner
import textract as tx
import pandas as pd
import os
import tf_idf
resume_dir = "Data/Resumes/"
job_desc_dir = "Data/JobDesc/"
resume_names = os.listdir(resume_dir)
job_description_names = os.listdir(job_desc_dir)
document = []
def read_resumes(list_of_resumes, resume_directory):
placeholder = []
for res in list_of_resumes:
temp = []
temp.append(res)
text = tx.process(resume_directory+res, encoding='ascii')
text = str(text, 'utf-8')
temp.append(text)
placeholder.append(temp)
return placeholder
document = read_resumes(resume_names, resume_dir)
def get_cleaned_words(document):
for i in range(len(document)):
raw = Cleaner.Cleaner(document[i][1])
document[i].append(" ".join(raw[0]))
document[i].append(" ".join(raw[1]))
document[i].append(" ".join(raw[2]))
sentence = tf_idf.do_tfidf(document[i][3].split(" "))
document[i].append(sentence)
return document
Doc = get_cleaned_words(document)
Database = pd.DataFrame(document, columns=[
"Name", "Context", "Cleaned", "Selective", "Selective_Reduced", "TF_Based"])
Database.to_csv("Resume_Data.csv", index=False)
# Database.to_json("Resume_Data.json", index=False)
def read_jobdescriptions(job_description_names, job_desc_dir):
placeholder = []
for tes in job_description_names:
temp = []
temp.append(tes)
text = tx.process(job_desc_dir+tes, encoding='ascii')
text = str(text, 'utf-8')
temp.append(text)
placeholder.append(temp)
return placeholder
job_document = read_jobdescriptions(job_description_names, job_desc_dir)
Jd = get_cleaned_words(job_document)
jd_database = pd.DataFrame(Jd, columns=[
"Name", "Context", "Cleaned", "Selective", "Selective_Reduced", "TF_Based"])
jd_database.to_csv("Job_Data.csv", index=False)