Added refractored Cosine ranker code for ranking.