build dictionary from list of words