build TF/IDF map and write to file