Repository: srbhr/Resume-Matcher
File: streamlit_app.py (Python)

Code before:
df2 = pd.DataFrame(selected_jd['keyterms'], columns=["keyword", "value"])

# Create the dictionary
keyword_dict = {}
for keyword, value in selected_jd['keyterms']:
    keyword_dict[keyword] = value * 100

fig = go.Figure(data=[go.Table(header=dict(values=["Keyword", "Value"],
                                           font=dict(size=12),
                                           fill_color='#070A52'),
                               cells=dict(values=[list(keyword_dict.keys()),
                                                  list(keyword_dict.values())],
                                          line_color='darkslategray',
                                          fill_color='#6DA9E4'))
                      ])
st.plotly_chart(fig)

st.divider()

fig = px.treemap(df2, path=['keyword'], values='value',
                 color_continuous_scale='Rainbow',
                 title='Key Terms/Topics Extracted from the selected Job Description')
st.write(fig)

avs.add_vertical_space(3)

config_file_path = config_path + "/config.yml"
if os.path.exists(config_file_path):
    config_data = read_config(config_file_path)
    if config_data:
        print("Config file parsed successfully:")
        resume_string = ' '.join(selected_file["extracted_keywords"])
        jd_string = ' '.join(selected_jd["extracted_keywords"])
        result = get_similarity_score(resume_string, jd_string)
        similarity_score = result[0]["score"]
        st.write("Similarity Score obtained for the resume and job description is:", similarity_score)
else:
    print("Config file does not exist.")


# Go back to top
st.markdown('[:arrow_up: Back to Top](#resume-matcher)')


Review comment (bug):
The refactoring update simplifies variable assignments and updates method access, which is good. A suggestion would include error handling around the new function `get_score` to ensure robustness.

Example:
```python
try:
    result = get_score(resume_string, jd_string)
    similarity_score = result[0].score
    st.write("Similarity Score obtained for the resume and job description is:", similarity_score)
except Exception as e:
    st.error(f"Failed to get similarity score: {e}")
```

Code after:

# Create the dictionary
keyword_dict = {}
for keyword, value in selected_jd['keyterms']:
    keyword_dict[keyword] = value * 100

fig = go.Figure(data=[go.Table(header=dict(values=["Keyword", "Value"],
                                           font=dict(size=12),
                                           fill_color='#070A52'),
                               cells=dict(values=[list(keyword_dict.keys()),
                                                  list(keyword_dict.values())],
                                          line_color='darkslategray',
                                          fill_color='#6DA9E4'))
                      ])
st.plotly_chart(fig)

st.divider()

fig = px.treemap(df2, path=['keyword'], values='value',
                 color_continuous_scale='Rainbow',
                 title='Key Terms/Topics Extracted from the selected Job Description')
st.write(fig)

avs.add_vertical_space(3)

resume_string = ' '.join(selected_file["extracted_keywords"])
jd_string = ' '.join(selected_jd["extracted_keywords"])
result = get_score(resume_string, jd_string)
similarity_score = result[0].score
st.write("Similarity Score obtained for the resume and job description is:", similarity_score)

# Go back to top
st.markdown('[:arrow_up: Back to Top](#resume-matcher)')