split writing to hdf5 in two groups: words and frequency