From 9033ec60ca21d43c1a7ed13785c4e864d8e47b77 Mon Sep 17 00:00:00 2001 From: queukat Date: Sat, 23 Nov 2024 18:30:59 +0300 Subject: [PATCH] fix --- answer_editor.py | 16 +++++++++++++--- cleanse_answers.py | 29 +++++++++++------------------ 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/answer_editor.py b/answer_editor.py index aa8ff2633..cedf30cb1 100644 --- a/answer_editor.py +++ b/answer_editor.py @@ -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) @@ -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 = [] @@ -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 @@ -51,4 +61,4 @@ def update(): return redirect(url_for('index')) if __name__ == '__main__': - app.run(debug=True) \ No newline at end of file + app.run(debug=True) diff --git a/cleanse_answers.py b/cleanse_answers.py index 22f3ee131..b4dee071a 100644 --- a/cleanse_answers.py +++ b/cleanse_answers.py @@ -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: @@ -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 = {