switch arguments to correct order for aref

 * in term-doc-freqs (aref result i) was mistakenly written as (aref i result)