<commit_before>/*
 * Copyright 2012-2016 <NAME>, <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package org.cherchgk.actions.tournament.result.ranking;

import org.cherchgk.domain.RightAnswer;
import org.cherchgk.domain.Team;
import org.cherchgk.domain.Tournament;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 * Алгоритм ранжирования команд на основе рейтинга взятых вопросов.
 *
 * @author <NAME> (<EMAIL>)
 */
public class RatingAlgorithm implements RankingAlgorithm {

    private static class RatingPoint extends RankingPoint<RatingPoint> {

        private Integer ratingPoint;

        private RatingPoint(Integer ratingPoint) {
            this.ratingPoint = ratingPoint;
        }

        @Override
        public int compareTo(RatingPoint o) {
            return ratingPoint.compareTo(o.ratingPoint);
        }

        @Override
        public String toString() {
            return ratingPoint.toString();
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) {
                return true;
            }
            if ((o == null) || (getClass() != o.getClass())) {
                return false;
            }

            RatingPoint that = (RatingPoint) o;
            return ratingPoint.equals(that.ratingPoint);
        }

        @Override
        public int hashCode() {
            return ratingPoint.hashCode();
        }
    }

    @Override
    public Map<Team, RankingPoint> getRankingPoints(Tournament tournament, Collection<Team> teams,
                                                    Collection<RightAnswer> rightAnswers) {
        int[] questionsRanking = new int[tournament.getQuestionAmount()];
        for (int i = 1; i < tournament.getQuestionAmount(); i++) {
            questionsRanking[i] = teams.size() + 1;
        }
        for (RightAnswer rightAnswer : rightAnswers) {
            questionsRanking[rightAnswer.getQuestionNumber() - 1]--;
        }
<commit_msg>Исправили ошибку.<commit_after>/*
 * Copyright 2012-2016 <NAME>, <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package org.cherchgk.actions.tournament.result.ranking;

import org.cherchgk.domain.RightAnswer;
import org.cherchgk.domain.Team;
import org.cherchgk.domain.Tournament;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 * Алгоритм ранжирования команд на основе рейтинга взятых вопросов.
 *
 * @author <NAME> (<EMAIL>)
 */
public class RatingAlgorithm implements RankingAlgorithm {

    private static class RatingPoint extends RankingPoint<RatingPoint> {

        private Integer ratingPoint;

        private RatingPoint(Integer ratingPoint) {
            this.ratingPoint = ratingPoint;
        }

        @Override
        public int compareTo(RatingPoint o) {
            return ratingPoint.compareTo(o.ratingPoint);
        }

        @Override
        public String toString() {
            return ratingPoint.toString();
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) {
                return true;
            }
            if ((o == null) || (getClass() != o.getClass())) {
                return false;
            }

            RatingPoint that = (RatingPoint) o;
            return ratingPoint.equals(that.ratingPoint);
        }

        @Override
        public int hashCode() {
            return ratingPoint.hashCode();
        }
    }

    @Override
    public Map<Team, RankingPoint> getRankingPoints(Tournament tournament, Collection<Team> teams,
                                                    Collection<RightAnswer> rightAnswers) {
        int[] questionsRanking = new int[tournament.getQuestionAmount()];
        for (int i = 0; i < tournament.getQuestionAmount(); i++) {
            questionsRanking[i] = teams.size() + 1;
        }
        for (RightAnswer rightAnswer : rightAnswers) {
            questionsRanking[rightAnswer.getQuestionNumber() - 1]--;
        }

{'fraction_non_alphanumeric': 0.09264358772619984, 'fraction_numerical': 0.005900865460267506, 'mean_word_length': 2.392261507671781, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6819794', 'n_tokens_mistral': 1380, 'n_tokens_neox': 1331, 'n_words': 403}