<commit_before>package com.tisawesomeness.minecord.debug;

import com.google.common.collect.EnumMultiset;
import com.google.common.collect.Multiset;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import net.dv8tion.jda.api.Region;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.sharding.ShardManager;
import net.dv8tion.jda.api.utils.MarkdownUtil;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

@RequiredArgsConstructor
public class RegionDebugOption implements DebugOption {

    private final @NonNull ShardManager shardManager;

    public @NonNull String getName() {
        return "region";
    }

    public @NonNull String debug() {
        List<Region> regions = shardManager.getGuilds().stream()
                .map(Guild::getRegion)
                .collect(Collectors.toList());
        Multiset<Region> regionCounts = EnumMultiset.create(regions);
        return Arrays.stream(Region.values())
                .filter(regionCounts::contains)
                .sorted()
                .map(r -> MarkdownUtil.bold(r.getName()) + " : " + regionCounts.count(r))
                .collect(Collectors.joining("\n"));
    }

}<commit_msg>Sort &debug region by count and add % display<commit_after>package com.tisawesomeness.minecord.debug;

import com.google.common.collect.EnumMultiset;
import com.google.common.collect.Multiset;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import net.dv8tion.jda.api.Region;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.sharding.ShardManager;
import net.dv8tion.jda.api.utils.MarkdownUtil;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

@RequiredArgsConstructor
public class RegionDebugOption implements DebugOption {

    private final @NonNull ShardManager shardManager;

    public @NonNull String getName() {
        return "region";
    }

    public @NonNull String debug() {
        List<Guild> guilds = shardManager.getGuilds();
        int total = guilds.size();
        List<Region> regions = guilds.stream()
                .map(Guild::getRegion)
                .collect(Collectors.toList());
        Multiset<Region> regionCounts = EnumMultiset.create(regions);
        return Arrays.stream(Region.values())
                .filter(regionCounts::contains)
                .sorted(Comparator.comparingInt(regionCounts::count))
                .map(r -> printCount(regionCounts, r, total))
                .collect(Collectors.joining("\n"));
    }

    private static @NonNull String printCount(Multiset<Region> regionCounts, Region r, int total) {
        int count = regionCounts.count(r);
        return String.format("%s | `%s` | `%.2f%%`", MarkdownUtil.bold(r.getName()), count, 100.0 * count / total);
    }

}
{'fraction_non_alphanumeric': 0.11873905429071804, 'fraction_numerical': 0.004553415061295972, 'mean_word_length': 3.294736842105263, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '4671333', 'n_tokens_mistral': 896, 'n_tokens_neox': 863, 'n_words': 160}