cm0805 commited on
Commit
b2045eb
1 Parent(s): 23aae0b

Update nlp.py

Browse files
Files changed (1) hide show
  1. nlp.py +9 -2
nlp.py CHANGED
@@ -21,7 +21,11 @@ from constants import StreamlitException
21
  from constants import API_URL_summary, API_URL_name, HEADERS, TECH_SKILLS
22
  from constants import SENTENCE_TRANSFORMER_MODEL, LLM_REPO_ID
23
 
 
 
 
24
  # Function to summarize resume text
 
25
  def summarize_text(text, max_length=100):
26
  if text != '':
27
  data = json.dumps(
@@ -42,6 +46,7 @@ def summarize_text(text, max_length=100):
42
  return 'nan'
43
 
44
  # Function to extract candidate name(s) from resume text
 
45
  def extract_person_names_and_email(text):
46
  print(text)
47
  emails = re.findall(r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b', text)
@@ -58,11 +63,12 @@ def extract_person_names_and_email(text):
58
  return set(person_names), set(emails)
59
 
60
  # Function to extract key technical skills from resume text
61
- def extract_tech_skills(doc):
62
- keywords = [token.text.upper() for token in doc if token.text.lower() in TECH_SKILLS]
63
  return set(keywords)
64
 
65
  # Function to calculate overall percentage match between job description and resume
 
66
  def calculate_similarity(job_description, resume):
67
  if job_description != '':
68
  model = SentenceTransformer(SENTENCE_TRANSFORMER_MODEL)
@@ -104,6 +110,7 @@ def split_text(string):
104
  return sentences
105
 
106
  # Function to calculate overall percentage match
 
107
  def get_average_similarity_scores(job_description, resumes):
108
  # Calculate cosine similarity matrix between job description and resumes
109
  model = SentenceTransformer(SENTENCE_TRANSFORMER_MODEL)
 
21
  from constants import API_URL_summary, API_URL_name, HEADERS, TECH_SKILLS
22
  from constants import SENTENCE_TRANSFORMER_MODEL, LLM_REPO_ID
23
 
24
+ from streamlit import cache_data
25
+
26
+
27
  # Function to summarize resume text
28
+ @cache_data(show_spinner=False)
29
  def summarize_text(text, max_length=100):
30
  if text != '':
31
  data = json.dumps(
 
46
  return 'nan'
47
 
48
  # Function to extract candidate name(s) from resume text
49
+ @cache_data(show_spinner=False)
50
  def extract_person_names_and_email(text):
51
  print(text)
52
  emails = re.findall(r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b', text)
 
63
  return set(person_names), set(emails)
64
 
65
  # Function to extract key technical skills from resume text
66
+ def extract_tech_skills(_doc):
67
+ keywords = [token.text.upper() for token in _doc if token.text.lower() in TECH_SKILLS]
68
  return set(keywords)
69
 
70
  # Function to calculate overall percentage match between job description and resume
71
+ @cache_data(show_spinner=False)
72
  def calculate_similarity(job_description, resume):
73
  if job_description != '':
74
  model = SentenceTransformer(SENTENCE_TRANSFORMER_MODEL)
 
110
  return sentences
111
 
112
  # Function to calculate overall percentage match
113
+ @cache_data(show_spinner=False)
114
  def get_average_similarity_scores(job_description, resumes):
115
  # Calculate cosine similarity matrix between job description and resumes
116
  model = SentenceTransformer(SENTENCE_TRANSFORMER_MODEL)