Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
queukat committed Nov 23, 2024
1 parent bd0f668 commit 9033ec6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
16 changes: 13 additions & 3 deletions answer_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
from pathlib import Path
from flask_bootstrap import Bootstrap
from src.ai_hawk.linkedIn_easy_applier import AIHawkEasyApplier

app = Flask(__name__)
Bootstrap(app)
Expand All @@ -26,6 +27,15 @@ def index():

return render_template('index.html', data=data if isinstance(data, list) else [])

easy_applier = AIHawkEasyApplier(
driver=None,
resume_dir=None,
set_old_answers=[],
gpt_answerer=None,
resume_generator_manager=None,
job_application_profile=None
)

def update():
if not JSON_FILE.exists():
data = []
Expand All @@ -37,9 +47,9 @@ def update():
for i, item in enumerate(data):
if f'delete_{i}' not in request.form:
if item['type'] == 'radio':
item['answer'] = request.form.get(f'answer_{i}_radio', item['answer'])
item['answer'] = easy_applier._sanitize_text(request.form.get(f'answer_{i}_radio', item['answer']))
else:
item['answer'] = request.form.get(f'answer_{i}', item['answer'])
item['answer'] = easy_applier._sanitize_text(request.form.get(f'answer_{i}', item['answer']))
updated_data.append(item)

# Sort updated data alphabetically by question
Expand All @@ -51,4 +61,4 @@ def update():
return redirect(url_for('index'))

if __name__ == '__main__':
app.run(debug=True)
app.run(debug=True)
29 changes: 11 additions & 18 deletions cleanse_answers.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
import json
import re

def sanitize_text(text: str) -> str:
# Remove duplicates by splitting and rejoining
text = text.rstrip()
text = re.sub(r'\s+', ' ', text)
text = text.replace('?', '').replace('"', '').replace('\\', '')
words = text.lower().split()
unique_words = []
for word in words:
if word not in unique_words:
unique_words.append(word)
text = ' '.join(unique_words)

# Remove common suffixes
text = re.sub(r'\s*\(?required\)?', '', text, flags=re.IGNORECASE)
text = re.sub(r'(\s*\(?yes\/no\)?|\s*\(?yes\)?|\s*\(?no\)?|\?)$', '', text, flags=re.IGNORECASE)
sanitized_text = re.sub(r'[^[:ascii:]]','', text)
return sanitized_text
from src.ai_hawk.linkedIn_easy_applier import AIHawkEasyApplier

easy_applier = AIHawkEasyApplier(
driver=None,
resume_dir=None,
set_old_answers=[],
gpt_answerer=None,
resume_generator_manager=None,
job_application_profile=None
)

def cleanse_answers_json(input_file: str, output_file: str):
with open(input_file, 'r') as f:
Expand All @@ -27,7 +20,7 @@ def cleanse_answers_json(input_file: str, output_file: str):
seen_questions = set()

for item in data:
sanitized_question = sanitize_text(item['question'])
sanitized_question = easy_applier._sanitize_text(item['question'])
if sanitized_question not in seen_questions:
seen_questions.add(sanitized_question)
cleansed_item = {
Expand Down

0 comments on commit 9033ec6

Please sign in to comment.