Skip to content

Commit

Permalink
Update notebook_utils.py
Browse files Browse the repository at this point in the history
Add function to select job description sentences and reformat them
  • Loading branch information
patw47 authored Oct 28, 2023
1 parent 72326f3 commit 31228e8
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion notebooks/notebook_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,36 @@ def extract_skills (s: str, language_list: List) -> tuple:
hard_skills.add(skill_name)
if skill_type == 'Soft Skill' and not skill_name.count('Language'):
soft_skills.add(skill_name)
return (', '.join(list(soft_skills)), ', '.join(list(hard_skills)), ', '.join(extract_languages(s, language_list)))
return (', '.join(list(soft_skills)), ', '.join(list(hard_skills)), ', '.join(extract_languages(s, language_list)))

# Function to randomly select n sentences and append them to the existing content with word replacements
def select_and_append_sentences(existing_text, sentences, n):
selected_sentences = random.sample(sentences, n)
appended_text = existing_text + " ".join(selected_sentences)

# Separate sentences with ". " only if it doesn't already exist
if not appended_text.endswith("."):
appended_text += ". "

# Remove sentences starting with "We offer you"
appended_text = re.sub(r'(?:^|\.)[^.]*\b(?:We offer).*?(?=\.)', '', appended_text)

# Replace "You are" with "I am" and "You have" with "I have"
appended_text = re.sub(r'\bYou are\b', 'I am', appended_text)
appended_text = re.sub(r'\bYou have\b', 'I have', appended_text)
appended_text = re.sub(r'\bWe are looking for\b', 'I am', appended_text)
appended_text = re.sub(r'\bOur requirement is for a\b', 'I am', appended_text)
appended_text = re.sub(r'\bIn this role\b', '', appended_text)
appended_text = re.sub(r'\bResponsibilities:\b', '', appended_text)
#appended_text = re.sub(r'\bWhat we offer:\b', '', appended_text)
#appended_text = re.sub(r'\bWhat we offer\b', '', appended_text)
appended_text = re.sub(r'\bis a must\b', '', appended_text)
appended_text = re.sub(r'\bYou will\b', 'I am able to', appended_text)
appended_text = re.sub(r'\bYou will be\b', 'I am', appended_text)
appended_text = re.sub(r'\bMust have built\b', 'Experience in', appended_text)
appended_text = re.sub(r'\Your role:\b', 'I', appended_text)
appended_text = re.sub(r'\Your responsibilities:\b', 'My experience:', appended_text)



return appended_text

0 comments on commit 31228e8

Please sign in to comment.