<commit_before>package dk.statsbiblioteket.medieplatform.newspaper.manualQA;


public class AverageHistogram {
    private static int NUMBER_OF_VALUES_IN_HISTOGRAM = 256;

    // Holds the sums of each value in the histograms for which this one is an average
    private long[] sumOfValue = new long[NUMBER_OF_VALUES_IN_HISTOGRAM];

    // The number of histograms, the values of which have been added to the array of sums
    private long histogramCount;


    public AverageHistogram() {
        resetAverageHistogram();
    }


    public void resetAverageHistogram() {
        for (int i = 0; i < NUMBER_OF_VALUES_IN_HISTOGRAM; i++) {
            sumOfValue[i] = 0;
        }
        histogramCount = 0;
    }


    public void addHistogram(long[] histogram) {
        for (int i = 0; i < NUMBER_OF_VALUES_IN_HISTOGRAM; i++) {
            sumOfValue[i] += histogram[i];
        }

        histogramCount++;
    }


    public long[] getAverageHistogramAsArray() {
        long[] averageOfValue = new long[NUMBER_OF_VALUES_IN_HISTOGRAM];

        for (int i = 0; i < NUMBER_OF_VALUES_IN_HISTOGRAM; i++) {
            averageOfValue[i] = sumOfValue[i] / histogramCount;
        }

        return averageOfValue;
    }<commit_msg>Review follow-up<commit_after>package dk.statsbiblioteket.medieplatform.newspaper.manualQA;

import java.util.Arrays;

/**
 * This class represents a histogram that is value-by-value average of several histgorams.
 */
public class AverageHistogram {
    private static int NUMBER_OF_VALUES_IN_HISTOGRAM = 256;

    // Holds the sums of each value in the histograms for which this one is an average
    private long[] sumOfValue = new long[NUMBER_OF_VALUES_IN_HISTOGRAM];

    // The number of histograms, the values of which have been added to the array of sums
    private long histogramCount;


    public AverageHistogram() {
    }


    public void resetAverageHistogram() {
        Arrays.fill(sumOfValue, 0);
        histogramCount = 0;
    }


    public void addHistogram(long[] histogram) {
        if (histogram.length != 256) {
            throw new IllegalArgumentException("Expected array of length 256");
        }

        for (int i = 0; i < NUMBER_OF_VALUES_IN_HISTOGRAM; i++) {
            sumOfValue[i] += histogram[i];
        }

        histogramCount++;
    }


    public long[] getAverageHistogramAsArray() {
        long[] averageOfValue = new long[NUMBER_OF_VALUES_IN_HISTOGRAM];

        for (int i = 0; i < NUMBER_OF_VALUES_IN_HISTOGRAM; i++) {
            averageOfValue[i] = sumOfValue[i] / histogramCount;
        }

        return averageOfValue;
    }
{'fraction_non_alphanumeric': 0.08604206500956023, 'fraction_numerical': 0.00803059273422562, 'mean_word_length': 2.7803468208092488, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 3, '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': '5567636', 'n_tokens_mistral': 888, 'n_tokens_neox': 790, 'n_words': 217}