Refactor class SimilarityMetric. Irrelevant classes are not changed and will probably be deleted in the future, so there are many errors now.