<commit_before>package szewek.fl.test;

import java.util.HashMap;
import java.util.Map;
import java.util.function.BiConsumer;

public final class NamedCounters {
	private static final Map<String, Counter> names = new HashMap<>();
	private static final Map<Counter, BiConsumer<String, Counter>> consumers = new HashMap<>();

	public static Counter getCounter(String n) {
		return names.computeIfAbsent(n, Counter::new);
	}

	public static void addConsumer(Counter c, BiConsumer<String, Counter> bic) {
		BiConsumer<String, Counter> obic = consumers.get(c);
		if (obic == null)
			consumers.put(c, bic);
		else
			consumers.put(c, obic.andThen(bic));
	}

	public static void checkAndResetAll() {
		for (Map.Entry<String, Counter> e : names.entrySet()) {
			Counter c = e.getValue();
			if (consumers.containsKey(c))
				consumers.get(c).accept(e.getKey(), c);
			c.count = 0;
		}
	}

	static final class Counter {
		private long count = 0;

		Counter(String x) {}

		public void add() {
			if (count < Long.MAX_VALUE)
				count++;
		}

		public boolean expect(long min, long max) {
			return count >= min && (min >= max || count <= max);
		}

		public long getCount() {
			return count;
		}
	}
}
<commit_msg>Make Counter public<commit_after>package szewek.fl.test;

import java.util.HashMap;
import java.util.Map;
import java.util.function.BiConsumer;

public final class NamedCounters {
	private static final Map<String, Counter> names = new HashMap<>();
	private static final Map<Counter, BiConsumer<String, Counter>> consumers = new HashMap<>();

	public static Counter getCounter(String n) {
		return names.computeIfAbsent(n, Counter::new);
	}

	public static void addConsumer(Counter c, BiConsumer<String, Counter> bic) {
		BiConsumer<String, Counter> obic = consumers.get(c);
		if (obic == null)
			consumers.put(c, bic);
		else
			consumers.put(c, obic.andThen(bic));
	}

	public static void checkAndResetAll() {
		for (Map.Entry<String, Counter> e : names.entrySet()) {
			Counter c = e.getValue();
			if (consumers.containsKey(c))
				consumers.get(c).accept(e.getKey(), c);
			c.count = 0;
		}
	}

	public static final class Counter {
		private long count = 0;

		Counter(String x) {}

		public void add() {
			if (count < Long.MAX_VALUE)
				count++;
		}

		public boolean expect(long min, long max) {
			return count >= min && (min >= max || count <= max);
		}

		public long getCount() {
			return count;
		}
	}
}

{'fraction_non_alphanumeric': 0.1360824742268041, 'fraction_numerical': 0.0016494845360824743, 'mean_word_length': 3.8911290322580645, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '970928', 'n_tokens_mistral': 903, 'n_tokens_neox': 789, 'n_words': 223}