Spaces:
Sleeping
Sleeping
Update app.py
Browse files1 unmodified line23455678911121310111212 unmodified lines252627322829303113 unmodified lines454647524849545556575859605051525354635556575859686061707172737475767762636479808165666783848586878889909192686970947172737429 unmodified lines1041051061301071081321091101341111121131381141151401161171421181191201211221481491231241251261272 unmodified lines1301311321581331341351361 unmodified lineimport requestsfrom bs4 import BeautifulSoupimport fitz # PyMuPDFimport spacyfrom sklearn.feature_extraction.text import TfidfVectorizerfrom sklearn.metrics.pairwise import cosine_similarityimport numpy as npimport re
# Carregar modelo de linguagem para NLPnlp = spacy.load("pt_core_news_sm")
# Configuração de coresTHEME = { "primary": "#1a1a2e", # Azul escuro12 unmodified lines response = requests.get(url, headers=headers) soup = BeautifulSoup(response.text, 'html.parser') # Tentativa de encontrar a descrição da vaga # Tentativa de encontrar a descrição da vaga description = soup.find('div', {'class': 'description__text'}) if not description: description = soup.find('div', {'class': 'show-more-less-html__markup'})13 unmodified lines except Exception as e: return f"Erro ao extrair texto do PDF: {str(e)}"
# Função para calcular similaridade# Função simplificada para calcular similaridade (sem spaCy)def calculate_match(job_text, resume_text): # Pré-processamento job_doc = nlp(job_text.lower()) resume_doc = nlp(resume_text.lower()) # Extrair palavras-chave job_keywords = [token.text for token in job_doc if not token.is_stop and not token.is_punct and token.is_alpha] resume_keywords = [token.text for token in resume_doc if not token.is_stop and not token.is_punct and token.is_alpha] # Pré-processamento básico job_text = job_text.lower() resume_text = resume_text.lower() # Vetorização e cálculo de similaridade vectorizer = TfidfVectorizer().fit_transform([' '.join(job_keywords), ' '.join(resume_keywords)]) vectorizer = TfidfVectorizer().fit_transform([job_text, resume_text]) similarity = cosine_similarity(vectorizer[0:1], vectorizer[1:2])[0][0] return round(similarity * 100, 2)
# Função para análise detalhada# Função para análise detalhada simplificadadef detailed_analysis(job_text, resume_text): job_doc = nlp(job_text.lower()) resume_doc = nlp(resume_text.lower()) # Extrair requisitos da vaga requirements = [] for sent in job_doc.sents: if "requisito" in sent.text or "necessário" in sent.text or "desejável" in sent.text: requirements.append(sent.text) # Extrair palavras-chave da vaga job_keywords = set(re.findall(r'\b\w{4,}\b', job_text.lower())) # Verificar correspondências matches = [] non_matches = [] # Verificar correspondências no currículo resume_words = set(re.findall(r'\b\w{4,}\b', resume_text.lower())) for req in requirements: req_doc = nlp(req) found = False for token in req_doc: if token.text in resume_text.lower(): matches.append(req) found = True break if not found: non_matches.append(req) matches = job_keywords & resume_words non_matches = job_keywords - resume_words return matches, non_matches return list(matches)[:10], list(non_matches)[:10] # Limitando a 10 itens cada
# Função principaldef analyze_match(job_url, resume_file):29 unmodified lines <div style='display: flex; justify-content: space-between; gap: 20px;'> <div style='flex: 1; background-color: {THEME["background"]}; padding: 15px; border-radius: 8px;'> <h3 style='color: {THEME["secondary"]};'>✔️ Correspondências Encontradas</h3> <h3 style='color: {THEME["secondary"]};'>✔️ Palavras-chave Correspondentes</h3> <ul> {''.join([f"<li style='margin-bottom: 8px;'>{match}</li>" for match in matches[:5]])} {''.join([f"<li style='margin-bottom: 8px;'>{match}</li>" for match in matches])} </ul> {f"<p>+ {len(matches)-5} outras correspondências...</p>" if len(matches) > 5 else ""} </div> <div style='flex: 1; background-color: {THEME["background"]}; padding: 15px; border-radius: 8px;'> <h3 style='color: {THEME["secondary"]};'>✖️ Requisitos Não Atendidos</h3> <h3 style='color: {THEME["secondary"]};'>✖️ Palavras-chave Faltantes</h3> <ul> {''.join([f"<li style='margin-bottom: 8px;'>{non_match}</li>" for non_match in non_matches[:5]])} {''.join([f"<li style='margin-bottom: 8px;'>{non_match}</li>" for non_match in non_matches])} </ul> {f"<p>+ {len(non_matches)-5} outros requisitos não atendidos...</p>" if len(non_matches) > 5 else ""} </div> </div> <div style='margin-top: 20px; background-color: {THEME["background"]}; padding: 15px; border-radius: 8px;'> <h3 style='color: {THEME["secondary"]};'>💡 Recomendações</h3> {f"<p style='color: #4CAF50;'>🎯 Você atende a maioria dos requisitos! Considere destacar {min(3, len(matches))} habilidades principais no topo do seu currículo.</p>" if match_percentage >= 70 else f"<p style='color: #F44336;'>🔍 Foque em desenvolver: {', '.join([nm.split()[0] for nm in non_matches[:3]])}</p>"} {f"<p style='color: #4CAF50;'>🎯 Seu currículo tem boa aderência à vaga! Considere destacar essas palavras-chave.</p>" if match_percentage >= 70 else f"<p style='color: #F44336;'>🔍 Foque em incluir estas palavras-chave no seu currículo: {', '.join(non_matches[:3])}</p>"} </div></div>"""2 unmodified lines except Exception as e: return f"❌ Ocorreu um erro durante a análise: {str(e)}"
# Interface Gradio com tema personalizado# Interface Gradiocss = f"""body {{ background-color: {THEME["primary"]} !important;app.py+21-46