MergeSort.sort(beforeSort, afterSort, tcp, null);
logger.info("Sorting categoryTokenCount.... done");
logger.info("Folding categoryTokenCount.... ");
// Now saves all this data to a FileCache
RecordReader tcrr= tcp.newRecordReader(afterSort);
TokenCounter catTc= new TokenCounter();
TokenCounter nonCatTc= new TokenCounter();
TokenCounterPersistence.TCRecord tcr= (TokenCounterPersistence.TCRecord) tcrr.readRecord();
if (null==tcrr) return;
catTc.update(tcr.getCatVal());
nonCatTc.update(tcr.getNonCatVal());
String prevToken= tcr.getToken();
while (null != (tcr= (TokenCounterPersistence.TCRecord) tcrr.readRecord())){
if (tcr.getToken().equals(prevToken)){
catTc.update(tcr.getCatVal());
nonCatTc.update(tcr.getNonCatVal());
} else {
computeProbs(prevToken, catTc, nonCatTc, tokenProbabilities);