<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Build feature matrix
The matrix is a JD-Skill matrix where each entry $e(d, s)$ is the number of times skill $s$ occurs in job description $d$.
Step1:  Get skills in each JD
Using the matrix, we can retrieve skills in each JD.
<ASSISTANT_TASK:>
Python Code:
doc_skill = buildDocSkillMat(jd_docs, skill_df, folder=SKILL_DIR)
with(open(SKILL_DIR + 'doc_skill.mtx', 'w')) as f:
    mmwrite(f, doc_skill)
Explanation: Build feature matrix
The matrix is a JD-Skill matrix where each entry $e(d, s)$ is the number of times skill $s$ occurs in job description $d$.
End of explanation
extracted_skill_df = getSkills4Docs(docs=doc_index['doc'], doc_term=doc_skill, skills=skills)
df = pd.merge(doc_index, extracted_skill_df, left_index=True, right_index=True)
print(df.shape)
df.head()
# sanity check
# df.head(3).to_csv(LDA_DIR + 'tmp/skills_3_sample_docs.csv', index=False)
df.to_csv(SKILL_DIR + 'doc_index.csv') # later no need to extract skill  again
Explanation: Get skills in each JD
Using the matrix, we can retrieve skills in each JD.
End of explanation
<END_TASK>