convert words into indices