Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,48 +3,40 @@ from docx import Document
|
|
3 |
import io
|
4 |
|
5 |
def read_docx(file_bytes):
|
6 |
-
# Use BytesIO to convert binary data to a file-like object for python-docx
|
7 |
file_like_object = io.BytesIO(file_bytes)
|
8 |
document = Document(file_like_object)
|
9 |
-
doc_text = []
|
10 |
-
|
11 |
-
for paragraph in document.paragraphs:
|
12 |
-
doc_text.append(paragraph.text)
|
13 |
-
|
14 |
-
# Join all text pieces and lower the case
|
15 |
return '\n'.join(doc_text).lower()
|
16 |
|
17 |
def analyze_cv(cv_file, desired_role, expected_salary):
|
18 |
-
# Define salary ranges for different roles
|
19 |
salary_ranges = {
|
20 |
-
"
|
21 |
-
"
|
22 |
-
"
|
23 |
}
|
24 |
|
25 |
-
# Read the content of the CV using the read_docx function
|
26 |
cv_content = read_docx(cv_file)
|
27 |
-
|
28 |
-
|
29 |
-
if desired_role.lower() in cv_content:
|
30 |
-
# Check if the expected salary is within the range for the role
|
31 |
salary_range = salary_ranges.get(desired_role, (0, 0))
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
36 |
else:
|
37 |
result = "El candidato no es elegible debido a la falta de experiencia relevante."
|
38 |
-
|
39 |
return result
|
40 |
|
41 |
-
# Define the Gradio interface with aesthetic enhancements
|
42 |
iface = gr.Interface(
|
43 |
fn=analyze_cv,
|
44 |
inputs=[
|
45 |
-
gr.File(label="Sube un CV", type="binary"),
|
46 |
gr.Textbox(label="Nombre del rol o posici贸n a cubrir", placeholder="Ejemplo: Desarrollador BI"),
|
47 |
-
gr.Textbox(label="Expectativa salarial", placeholder="Ejemplo: 50000"),
|
48 |
],
|
49 |
outputs=gr.Textbox(label="Resultado de la elegibilidad"),
|
50 |
title="An谩lisis autom谩tico de CV",
|
@@ -56,9 +48,8 @@ iface = gr.Interface(
|
|
56 |
.gr-file { border-color: #007BFF; }
|
57 |
.gr-button { background-color: #007BFF; color: white; }
|
58 |
.gr-output-text { font-size: 16px; }
|
59 |
-
"""
|
60 |
-
share=True # Set share=True to create a public link
|
61 |
)
|
62 |
|
63 |
-
# Launch the application
|
64 |
-
iface.launch()
|
|
|
3 |
import io
|
4 |
|
5 |
def read_docx(file_bytes):
|
|
|
6 |
file_like_object = io.BytesIO(file_bytes)
|
7 |
document = Document(file_like_object)
|
8 |
+
doc_text = [paragraph.text for paragraph in document.paragraphs]
|
|
|
|
|
|
|
|
|
|
|
9 |
return '\n'.join(doc_text).lower()
|
10 |
|
11 |
def analyze_cv(cv_file, desired_role, expected_salary):
|
|
|
12 |
salary_ranges = {
|
13 |
+
"desarrollador": (30000, 60000),
|
14 |
+
"dise帽ador": (25000, 50000),
|
15 |
+
"gerente": (40000, 80000)
|
16 |
}
|
17 |
|
|
|
18 |
cv_content = read_docx(cv_file)
|
19 |
+
desired_role = desired_role.lower()
|
20 |
+
if desired_role in cv_content:
|
|
|
|
|
21 |
salary_range = salary_ranges.get(desired_role, (0, 0))
|
22 |
+
try:
|
23 |
+
expected_salary = int(expected_salary)
|
24 |
+
if salary_range[0] <= expected_salary <= salary_range[1]:
|
25 |
+
result = "El candidato es elegible para la posici贸n."
|
26 |
+
else:
|
27 |
+
result = "El candidato no es elegible debido a las expectativas salariales."
|
28 |
+
except ValueError:
|
29 |
+
result = "Por favor, ingrese un valor num茅rico v谩lido para la expectativa salarial."
|
30 |
else:
|
31 |
result = "El candidato no es elegible debido a la falta de experiencia relevante."
|
|
|
32 |
return result
|
33 |
|
|
|
34 |
iface = gr.Interface(
|
35 |
fn=analyze_cv,
|
36 |
inputs=[
|
37 |
+
gr.File(label="Sube un CV", type="binary"),
|
38 |
gr.Textbox(label="Nombre del rol o posici贸n a cubrir", placeholder="Ejemplo: Desarrollador BI"),
|
39 |
+
gr.Textbox(label="Expectativa salarial", placeholder="Ejemplo: 50000"),
|
40 |
],
|
41 |
outputs=gr.Textbox(label="Resultado de la elegibilidad"),
|
42 |
title="An谩lisis autom谩tico de CV",
|
|
|
48 |
.gr-file { border-color: #007BFF; }
|
49 |
.gr-button { background-color: #007BFF; color: white; }
|
50 |
.gr-output-text { font-size: 16px; }
|
51 |
+
"""
|
|
|
52 |
)
|
53 |
|
54 |
+
# Launch the application with share=True to create a public link
|
55 |
+
iface.launch(share=True)
|