Refactor Precision and Recall with generics and inheritance