implements most of the ranking algo
implements ranking for documents and annotations