Skip to content

Commit

Permalink
09c5fd6-deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
krugergui committed Oct 29, 2023
2 parents 09c5fd6 + 90f7be4 commit 08263f5
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/backend/api/matching_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,25 @@ def get_free_text_match(
float: a number from -1 to 1 indicating cosine similarity
"""

if (candidate_embeddings) == None or (job_embeddings) == None:
return 0

if candidate_embeddings == "" or type(job_embeddings) == "":
return 0

candidate_embeddings = json.loads(candidate_embeddings)
job_embeddings = json.loads(job_embeddings)

return cosine_similarity(candidate_embeddings, job_embeddings)[0][0] * 100

if __name__=="__main__":
print(int(get_free_text_match(
torch.tensor([[1,0,0]]),
torch.tensor([[-1,0,0]]),
))==-1)


if __name__ == "__main__":
print(
int(
get_free_text_match(
torch.tensor([[1, 0, 0]]),
torch.tensor([[-1, 0, 0]]),
)
)
== -1
)

0 comments on commit 08263f5

Please sign in to comment.