Spaces:
Runtime error
Runtime error
start building out specific job-candidate match functionality
Browse files- main.py +13 -6
- match_utils.py +20 -0
- static/res_embeddings.csv +0 -0
main.py
CHANGED
@@ -18,7 +18,7 @@ from localStoragePy import localStoragePy
|
|
18 |
localStorage = localStoragePy('pathfinder', 'text')
|
19 |
|
20 |
from scrape_onet import get_onet_code, get_onet_description, get_onet_tasks
|
21 |
-
from match_utils import neighborhoods, get_resume, skillNER, sim_result_loop, get_links, coSkillEmbed
|
22 |
from user_utils import Hash
|
23 |
|
24 |
# APP SETUP
|
@@ -143,19 +143,22 @@ def get_matches(request: Request):
|
|
143 |
@app.post('/find-my-match/', response_class=HTMLResponse)
|
144 |
async def post_matches(request: Request, bt: BackgroundTasks, resume: UploadFile = File(...)):
|
145 |
|
146 |
-
resume = get_resume(resume)
|
147 |
-
username = localStorage.getItem('username')
|
148 |
-
db = pd.read_csv('static/res_embeddings.csv')
|
149 |
-
|
150 |
def add_data_to_db(resume, db, username):
|
151 |
embeds = format(coSkillEmbed(resume)).replace('[[','').replace(']]','').split(',')
|
152 |
db.iloc[db['username']== username,5:] = embeds
|
153 |
db.to_csv('static/res_embeddings.csv', index=False)
|
|
|
|
|
|
|
|
|
154 |
|
155 |
skills = await skillNER(resume)
|
156 |
simResults = await sim_result_loop(resume)
|
157 |
links = get_links(simResults[0])
|
158 |
|
|
|
|
|
|
|
159 |
bt.add_task(add_data_to_db, resume, db, username)
|
160 |
|
161 |
return templates.TemplateResponse('find_my_match.html', context={'request': request, 'resume': resume, 'skills': skills, 'simResults': simResults[0], 'links': links})
|
@@ -195,4 +198,8 @@ async def post_matches(request: Request, bt: BackgroundTasks, jobdesc: UploadFil
|
|
195 |
def find_hire(request: Request):
|
196 |
jobselection = str(request.url).split("=")[1].replace('HTTP/1.1', '').replace("-", " ")
|
197 |
print(jobselection)
|
198 |
-
return templates.TemplateResponse('find_hire.html', context={'request': request, 'jobselection': jobselection})
|
|
|
|
|
|
|
|
|
|
18 |
localStorage = localStoragePy('pathfinder', 'text')
|
19 |
|
20 |
from scrape_onet import get_onet_code, get_onet_description, get_onet_tasks
|
21 |
+
from match_utils import neighborhoods, get_resume, skillNER, sim_result_loop, get_links, coSkillEmbed, sim_result_loop_jobFinder
|
22 |
from user_utils import Hash
|
23 |
|
24 |
# APP SETUP
|
|
|
143 |
@app.post('/find-my-match/', response_class=HTMLResponse)
|
144 |
async def post_matches(request: Request, bt: BackgroundTasks, resume: UploadFile = File(...)):
|
145 |
|
|
|
|
|
|
|
|
|
146 |
def add_data_to_db(resume, db, username):
|
147 |
embeds = format(coSkillEmbed(resume)).replace('[[','').replace(']]','').split(',')
|
148 |
db.iloc[db['username']== username,5:] = embeds
|
149 |
db.to_csv('static/res_embeddings.csv', index=False)
|
150 |
+
|
151 |
+
resume = get_resume(resume)
|
152 |
+
username = localStorage.getItem('username')
|
153 |
+
db = pd.read_csv('static/res_embeddings.csv')
|
154 |
|
155 |
skills = await skillNER(resume)
|
156 |
simResults = await sim_result_loop(resume)
|
157 |
links = get_links(simResults[0])
|
158 |
|
159 |
+
job_matches = await sim_result_loop_jobFinder(resume)
|
160 |
+
print(job_matches)
|
161 |
+
|
162 |
bt.add_task(add_data_to_db, resume, db, username)
|
163 |
|
164 |
return templates.TemplateResponse('find_my_match.html', context={'request': request, 'resume': resume, 'skills': skills, 'simResults': simResults[0], 'links': links})
|
|
|
198 |
def find_hire(request: Request):
|
199 |
jobselection = str(request.url).split("=")[1].replace('HTTP/1.1', '').replace("-", " ")
|
200 |
print(jobselection)
|
201 |
+
return templates.TemplateResponse('find_hire.html', context={'request': request, 'jobselection': jobselection})
|
202 |
+
|
203 |
+
@app.get("/find-job/", response_class=HTMLResponse)
|
204 |
+
def find_job(request: Request):
|
205 |
+
pass
|
match_utils.py
CHANGED
@@ -118,3 +118,23 @@ def get_links(simResults):
|
|
118 |
titles = simResults["JobTitle"]
|
119 |
[links.append("https://www.onetonline.org/link/summary/" + get_onet_code(title)) for title in titles]
|
120 |
return links
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
titles = simResults["JobTitle"]
|
119 |
[links.append("https://www.onetonline.org/link/summary/" + get_onet_code(title)) for title in titles]
|
120 |
return links
|
121 |
+
|
122 |
+
async def sim_result_loop_jobFinder(resume):
|
123 |
+
embeds = coSkillEmbed(resume)
|
124 |
+
def cosine(A, B):
|
125 |
+
return np.dot(A,B)/(norm(A)*norm(B))
|
126 |
+
def format_sim(sim):
|
127 |
+
return "{:0.2f}".format(sim)
|
128 |
+
jobdat = pd.read_csv('static/jd_embeddings.csv')
|
129 |
+
jobembeds = jobdat.iloc[:,5:].dropna()
|
130 |
+
simResults = []
|
131 |
+
[simResults.append(cosine(np.array(embeds), np.array(jobembeds.iloc[i,:]))) for i in range(len(jobembeds))]
|
132 |
+
simResults = pd.DataFrame(simResults)
|
133 |
+
simResults['job_id'] = jobdat['id']
|
134 |
+
simResults = simResults.iloc[:,[1,0]]
|
135 |
+
simResults.columns = ['job_id', 'Similarity']
|
136 |
+
simResults = simResults.sort_values(by = "Similarity", ascending = False)
|
137 |
+
simResults.reset_index(drop=True, inplace=True)
|
138 |
+
for x in range(len(simResults)):
|
139 |
+
simResults.iloc[x,1] = format_sim(simResults.iloc[x,1])
|
140 |
+
return simResults
|
static/res_embeddings.csv
CHANGED
The diff for this file is too large to render.
See raw diff
|
|