Fix bugs in calculation and presentation of perplexity for train and query segments