Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -708,6 +708,87 @@ def process_pdf(file):
|
|
| 708 |
error_message = f"Error processing PDF: {str(e)}"
|
| 709 |
return error_message, error_message
|
| 710 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 711 |
with gr.Blocks() as demo:
|
| 712 |
gr.Markdown("# Standardize Job Description!")
|
| 713 |
gr.Markdown("Identify Job Family, Occupation, Qualification, match Skills and suggest interview questions.")
|
|
@@ -727,7 +808,7 @@ with gr.Blocks() as demo:
|
|
| 727 |
with gr.Row():
|
| 728 |
with gr.Column():
|
| 729 |
gr.Markdown("## CCOG Levels")
|
| 730 |
-
ccoq_levels_output = gr.JSON(label="CCOG Levels"
|
| 731 |
|
| 732 |
with gr.Row():
|
| 733 |
with gr.Column():
|
|
@@ -737,17 +818,21 @@ with gr.Blocks() as demo:
|
|
| 737 |
with gr.Row():
|
| 738 |
with gr.Column():
|
| 739 |
gr.Markdown("## Skills")
|
| 740 |
-
skills_output = gr.JSON(label="Skills"
|
| 741 |
|
| 742 |
with gr.Row():
|
| 743 |
with gr.Column():
|
| 744 |
gr.Markdown("## ESCO Levels")
|
| 745 |
-
esco_levels_output = gr.JSON(label="ESCO Levels"
|
| 746 |
|
| 747 |
with gr.Row():
|
| 748 |
with gr.Column():
|
| 749 |
gr.Markdown("## ESCO Skills")
|
| 750 |
-
esco_skills_output = gr.JSON(label="ESCO Skills"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 751 |
|
| 752 |
if DEBUG:
|
| 753 |
with gr.Row():
|
|
@@ -777,5 +862,14 @@ with gr.Blocks() as demo:
|
|
| 777 |
]
|
| 778 |
)
|
| 779 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 780 |
if __name__ == "__main__":
|
| 781 |
demo.launch(show_error=True, debug=DEBUG)
|
|
|
|
|
|
|
|
|
| 708 |
error_message = f"Error processing PDF: {str(e)}"
|
| 709 |
return error_message, error_message
|
| 710 |
|
| 711 |
+
from docx import Document
|
| 712 |
+
|
| 713 |
+
def generate_word_document(result):
|
| 714 |
+
doc = Document()
|
| 715 |
+
|
| 716 |
+
# Add a title
|
| 717 |
+
doc.add_heading('Job Description Analysis', level=1)
|
| 718 |
+
|
| 719 |
+
# Add file name
|
| 720 |
+
doc.add_heading('File Name', level=2)
|
| 721 |
+
doc.add_paragraph(result["file"])
|
| 722 |
+
|
| 723 |
+
# Add responsibilities
|
| 724 |
+
doc.add_heading('Responsibilities', level=2)
|
| 725 |
+
doc.add_paragraph(result["responsibilities"])
|
| 726 |
+
|
| 727 |
+
# Add job family
|
| 728 |
+
doc.add_heading('Classified Job Family', level=2)
|
| 729 |
+
doc.add_paragraph(result["classified_job_family"])
|
| 730 |
+
|
| 731 |
+
# Add qualifications
|
| 732 |
+
doc.add_heading('Qualification', level=2)
|
| 733 |
+
doc.add_paragraph("\n".join(result["qualification"]))
|
| 734 |
+
|
| 735 |
+
# Add CCOG Levels
|
| 736 |
+
doc.add_heading('CCOG Levels', level=2)
|
| 737 |
+
for i in range(1, 5):
|
| 738 |
+
for field in ["code", "name", "desc"]:
|
| 739 |
+
key = f"Level_{i}_CCOG_{field}"
|
| 740 |
+
if key in result:
|
| 741 |
+
doc.add_paragraph(f"{key}: {result[key]}")
|
| 742 |
+
|
| 743 |
+
# Add interview questions
|
| 744 |
+
doc.add_heading('Interview Questions', level=2)
|
| 745 |
+
doc.add_paragraph("\n".join(result["interview"]))
|
| 746 |
+
|
| 747 |
+
# Add skills
|
| 748 |
+
doc.add_heading('Skills', level=2)
|
| 749 |
+
for skill in result["skills"]["skills"]:
|
| 750 |
+
doc.add_paragraph(f"Skill Name: {skill['skill_name']}")
|
| 751 |
+
doc.add_paragraph(f"Description: {skill['skill_description']}")
|
| 752 |
+
doc.add_paragraph(f"Code: {skill['skill_code']}")
|
| 753 |
+
doc.add_paragraph(f"Importance: {skill.get('importance', 'N/A')}")
|
| 754 |
+
doc.add_paragraph(f"Type: {skill.get('type', 'N/A')}")
|
| 755 |
+
doc.add_paragraph(f"Proficiency Level: {skill.get('proficiency_level', 'N/A')}")
|
| 756 |
+
doc.add_paragraph(f"Distinctive Elements: {skill.get('distinctive_elements', 'N/A')}")
|
| 757 |
+
doc.add_paragraph(f"Resume Signals: {skill.get('resume_signals', 'N/A')}")
|
| 758 |
+
doc.add_paragraph(f"Assessment Method: {skill.get('assessment_method', 'N/A')}")
|
| 759 |
+
doc.add_paragraph("") # Add an empty line for separation
|
| 760 |
+
|
| 761 |
+
# Add ESCO Levels if available
|
| 762 |
+
if "skills_esco" in result and result["skills_esco"]:
|
| 763 |
+
doc.add_heading('ESCO Levels', level=2)
|
| 764 |
+
for i in range(1, 6):
|
| 765 |
+
for field in ["code", "name", "desc"]:
|
| 766 |
+
key = f"Level_{i}_ESCO_{field}"
|
| 767 |
+
if key in result:
|
| 768 |
+
doc.add_paragraph(f"{key}: {result[key]}")
|
| 769 |
+
|
| 770 |
+
# Add ESCO Skills
|
| 771 |
+
doc.add_heading('ESCO Skills', level=2)
|
| 772 |
+
for skill in result["skills_esco"]["skills"]:
|
| 773 |
+
doc.add_paragraph(f"Skill Name: {skill['skill_name']}")
|
| 774 |
+
doc.add_paragraph(f"Description: {skill['skill_description']}")
|
| 775 |
+
doc.add_paragraph(f"Code: {skill['skill_code']}")
|
| 776 |
+
doc.add_paragraph(f"Importance: {skill.get('importance', 'N/A')}")
|
| 777 |
+
doc.add_paragraph(f"Type: {skill.get('type', 'N/A')}")
|
| 778 |
+
doc.add_paragraph(f"Proficiency Level: {skill.get('proficiency_level', 'N/A')}")
|
| 779 |
+
doc.add_paragraph(f"Distinctive Elements: {skill.get('distinctive_elements', 'N/A')}")
|
| 780 |
+
doc.add_paragraph(f"Resume Signals: {skill.get('resume_signals', 'N/A')}")
|
| 781 |
+
doc.add_paragraph(f"Assessment Method: {skill.get('assessment_method', 'N/A')}")
|
| 782 |
+
doc.add_paragraph("") # Add an empty line for separation
|
| 783 |
+
|
| 784 |
+
# Save the document to a temporary file
|
| 785 |
+
temp_file_path = "job_description_analysis.docx"
|
| 786 |
+
doc.save(temp_file_path)
|
| 787 |
+
|
| 788 |
+
return temp_file_path
|
| 789 |
+
|
| 790 |
+
|
| 791 |
+
|
| 792 |
with gr.Blocks() as demo:
|
| 793 |
gr.Markdown("# Standardize Job Description!")
|
| 794 |
gr.Markdown("Identify Job Family, Occupation, Qualification, match Skills and suggest interview questions.")
|
|
|
|
| 808 |
with gr.Row():
|
| 809 |
with gr.Column():
|
| 810 |
gr.Markdown("## CCOG Levels")
|
| 811 |
+
ccoq_levels_output = gr.JSON(label="CCOG Levels")
|
| 812 |
|
| 813 |
with gr.Row():
|
| 814 |
with gr.Column():
|
|
|
|
| 818 |
with gr.Row():
|
| 819 |
with gr.Column():
|
| 820 |
gr.Markdown("## Skills")
|
| 821 |
+
skills_output = gr.JSON(label="Skills")
|
| 822 |
|
| 823 |
with gr.Row():
|
| 824 |
with gr.Column():
|
| 825 |
gr.Markdown("## ESCO Levels")
|
| 826 |
+
esco_levels_output = gr.JSON(label="ESCO Levels")
|
| 827 |
|
| 828 |
with gr.Row():
|
| 829 |
with gr.Column():
|
| 830 |
gr.Markdown("## ESCO Skills")
|
| 831 |
+
esco_skills_output = gr.JSON(label="ESCO Skills")
|
| 832 |
+
|
| 833 |
+
with gr.Row():
|
| 834 |
+
with gr.Column():
|
| 835 |
+
download_btn = gr.Button("Download Word Document")
|
| 836 |
|
| 837 |
if DEBUG:
|
| 838 |
with gr.Row():
|
|
|
|
| 862 |
]
|
| 863 |
)
|
| 864 |
|
| 865 |
+
download_btn.click(
|
| 866 |
+
fn=generate_word_document,
|
| 867 |
+
inputs=[file_name_output, responsibilities_output, job_family_output, qualification_output,
|
| 868 |
+
ccoq_levels_output, interview_output, skills_output, esco_levels_output, esco_skills_output],
|
| 869 |
+
outputs=gr.File(label="Download Word Document")
|
| 870 |
+
)
|
| 871 |
+
|
| 872 |
if __name__ == "__main__":
|
| 873 |
demo.launch(show_error=True, debug=DEBUG)
|
| 874 |
+
|
| 875 |
+
|