<commit_before>package fi.evident.fab.proq2

import fi.evident.fab.rew.FilterConfiguration
import java.io.IOException
import java.io.OutputStream

object PresetWriter {

    private val maximumNumberOfFilters = 24

    @Throws(IOException::class)
    fun writePreset(filterConfigurations: List<FilterConfiguration>,
                    globalParameters: GlobalPresetParameters,
                    outputStream: OutputStream) {

        val numberOfFilters = filterConfigurations.sumBy { it.filters.size }

        if (numberOfFilters > maximumNumberOfFilters)
            throw IllegalArgumentException("Filters are limited to 24, was: $numberOfFilters")

        val writer = LittleEndianBinaryStreamWriter(outputStream)

        writer.writeBytes("FQ2p".toByteArray())
        writer.writeInt(2)
        writer.writeInt(190)

        for (filterConfiguration in filterConfigurations) {

            val slope = BandSlope.of(filterConfiguration.slope)
            val placement = BandPlacement.of(filterConfiguration.placement)

            for (filter in filterConfiguration.filters)
                Band.fromRewFilter(filter, slope, placement).write(writer)
        }

        for (i in 0..maximumNumberOfFilters - numberOfFilters - 1)
            Band.unusedBand.write(writer)

        globalParameters.write(writer)
    }
}<commit_msg>repeat<commit_after>package fi.evident.fab.proq2

import fi.evident.fab.rew.FilterConfiguration
import java.io.IOException
import java.io.OutputStream

object PresetWriter {

    private val maximumNumberOfFilters = 24

    @Throws(IOException::class)
    fun writePreset(filterConfigurations: List<FilterConfiguration>,
                    globalParameters: GlobalPresetParameters,
                    outputStream: OutputStream) {

        val numberOfFilters = filterConfigurations.sumBy { it.filters.size }

        if (numberOfFilters > maximumNumberOfFilters)
            throw IllegalArgumentException("Filters are limited to 24, was: $numberOfFilters")

        val writer = LittleEndianBinaryStreamWriter(outputStream)

        writer.writeBytes("FQ2p".toByteArray())
        writer.writeInt(2)
        writer.writeInt(190)

        for (filterConfiguration in filterConfigurations) {

            val slope = BandSlope.of(filterConfiguration.slope)
            val placement = BandPlacement.of(filterConfiguration.placement)

            for (filter in filterConfiguration.filters)
                Band.fromRewFilter(filter, slope, placement).write(writer)
        }

        repeat(maximumNumberOfFilters - numberOfFilters) {
            Band.unusedBand.write(writer)
        }

        globalParameters.write(writer)
    }
}
{'fraction_non_alphanumeric': 0.07732536421367202, 'fraction_numerical': 0.008218154650728428, 'mean_word_length': 2.9209370424597365, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '5007298', 'n_tokens_mistral': 707, 'n_tokens_neox': 677, 'n_words': 132}