Spaces:
Runtime error
Runtime error
sandrocalzada
commited on
Commit
•
b0e3d64
1
Parent(s):
0e2ee45
Update app.py
Browse files
app.py
CHANGED
@@ -1,41 +1,62 @@
|
|
1 |
-
|
2 |
-
import
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import io
|
3 |
+
|
4 |
+
def read_docx(file_bytes):
|
5 |
+
|
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 |
+
|
10 |
+
|
11 |
+
|
12 |
+
|
13 |
+
|
14 |
+
return '\n'.join(doc_text).lower()
|
15 |
+
|
16 |
+
def analyze_cv(cv_file, desired_role, expected_salary):
|
17 |
+
|
18 |
+
salary_ranges = {
|
19 |
+
"desarrollador": (30000, 60000),
|
20 |
+
"diseñador": (25000, 50000),
|
21 |
+
"gerente": (40000, 80000)
|
22 |
+
}
|
23 |
+
|
24 |
+
|
25 |
+
cv_content = read_docx(cv_file)
|
26 |
+
desired_role = desired_role.lower()
|
27 |
+
if desired_role in cv_content:
|
28 |
+
|
29 |
+
|
30 |
+
salary_range = salary_ranges.get(desired_role, (0, 0))
|
31 |
+
try:
|
32 |
+
expected_salary = int(expected_salary)
|
33 |
+
if salary_range[0] <= expected_salary <= salary_range[1]:
|
34 |
+
result = "El candidato es elegible para la posición."
|
35 |
+
else:
|
36 |
+
result = "El candidato no es elegible debido a las expectativas salariales."
|
37 |
+
except ValueError:
|
38 |
+
result = "Por favor, ingrese un valor numérico válido para la expectativa salarial."
|
39 |
+
else:
|
40 |
+
result = "El candidato no es elegible debido a la falta de experiencia relevante."
|
41 |
+
|
42 |
+
return result
|
43 |
+
|
44 |
+
|
45 |
+
iface = gr.Interface(
|
46 |
+
fn=analyze_cv,
|
47 |
+
inputs=[
|
48 |
+
gr.File(label="Sube un CV", type="binary"),
|
49 |
+
gr.Textbox(label="Nombre del rol o posición a cubrir", placeholder="Ejemplo: Desarrollador BI"),
|
50 |
+
gr.Textbox(label="Expectativa salarial", placeholder="Ejemplo: 50000"),
|
51 |
+
],
|
52 |
+
outputs=gr.Textbox(label="Resultado de la elegibilidad"),
|
53 |
+
title="Análisis automático de CV",
|
54 |
+
.gr-file { border-color: #007BFF; }
|
55 |
+
.gr-button { background-color: #007BFF; color: white; }
|
56 |
+
.gr-output-text { font-size: 16px; }
|
57 |
+
"""
|
58 |
+
|
59 |
+
)
|
60 |
+
|
61 |
+
# Launch the application with share=True to create a public link
|
62 |
+
iface.launch(share=True)
|