<commit_before>package uk.ac.ebi.quickgo.annotation.service.statistics;

import uk.ac.ebi.quickgo.annotation.model.AnnotationRequest;
import uk.ac.ebi.quickgo.annotation.model.StatisticsByType;
import uk.ac.ebi.quickgo.annotation.model.StatisticsGroup;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;

import static java.util.Collections.emptyList;
import static uk.ac.ebi.quickgo.annotation.model.AnnotationRequest.SLIM_USAGE;
import static uk.ac.ebi.quickgo.annotation.service.statistics.RequiredStatisticType.statsType;
import static uk.ac.ebi.quickgo.annotation.service.statistics.RequiredStatistics.DEFAULT_GO_TERM_LIMIT;

/**
 * // TODO: 21/11/17
 * Created 21/11/17
 * @author Edd
 */
class SlimmedStatsHelper {
    private SlimmedStatsHelper() {}

    static <T> Optional<T> extractMatchingStat(Collection<T> statInfos, Function<T, String> valueSource,
            String statValue) {
        return statInfos.stream()
                .filter(value -> valueSource.apply(value).equals(statValue))
                .findFirst();
    }

    static List<RequiredStatistic> updateRequiredStatsForSlimming(List<RequiredStatistic> requiredStatistics) {
        List<RequiredStatistic> requiredStatisticsForSlimUsage = new ArrayList<>();

        requiredStatistics.stream()
                .map(SlimmedStatsHelper::slimmedStat)
                .forEach(requiredStatisticsForSlimUsage::add);
<commit_msg>javadoc for slim helper class<commit_after>package uk.ac.ebi.quickgo.annotation.service.statistics;

import uk.ac.ebi.quickgo.annotation.model.AnnotationRequest;
import uk.ac.ebi.quickgo.annotation.model.StatisticsByType;
import uk.ac.ebi.quickgo.annotation.model.StatisticsGroup;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;

import static java.util.Collections.emptyList;
import static uk.ac.ebi.quickgo.annotation.model.AnnotationRequest.SLIM_USAGE;
import static uk.ac.ebi.quickgo.annotation.service.statistics.RequiredStatisticType.statsType;
import static uk.ac.ebi.quickgo.annotation.service.statistics.RequiredStatistics.DEFAULT_GO_TERM_LIMIT;

/**
 * Contains methods common to slimming.
 * 
 * Created 21/11/17
 * @author Edd
 */
class SlimmedStatsHelper {
    private SlimmedStatsHelper() {}

    static <T> Optional<T> extractMatchingStat(Collection<T> statInfos, Function<T, String> valueSource,
            String statValue) {
        return statInfos.stream()
                .filter(value -> valueSource.apply(value).equals(statValue))
                .findFirst();
    }

    static List<RequiredStatistic> updateRequiredStatsForSlimming(List<RequiredStatistic> requiredStatistics) {
        List<RequiredStatistic> requiredStatisticsForSlimUsage = new ArrayList<>();

        requiredStatistics.stream()
                .map(SlimmedStatsHelper::slimmedStat)
                .forEach(requiredStatisticsForSlimUsage::add);

{'fraction_non_alphanumeric': 0.10437932169904511, 'fraction_numerical': 0.005926901547579849, 'mean_word_length': 4.283478260869566, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4675305', 'n_tokens_mistral': 900, 'n_tokens_neox': 873, 'n_words': 139}