<commit_before>package net.bjoernpetersen.musicbot.api.config

interface ConfigSerializer<T> {
    /**
     * Serializes the given object to a string.
     *
     * This operation should not fail.
     */
    fun serialize(obj: T): String

    /**
     * Deserializes the given string.
     *
     * @throws SerializationException if the string can't be deserialized
     */
    @Throws(SerializationException::class)
    fun deserialize(string: String): T
}

class SerializationException : Exception()

object IntSerializer : ConfigSerializer<Int> {
    override fun serialize(obj: Int): String = obj.toString()
    @Throws(SerializationException::class)
    override fun deserialize(string: String): Int = string.toIntOrNull()
        ?: throw SerializationException()
}<commit_msg>Add FileConfigSerializer<commit_after>package net.bjoernpetersen.musicbot.api.config

import java.io.File

interface ConfigSerializer<T> {
    /**
     * Serializes the given object to a string.
     *
     * This operation should not fail.
     */
    fun serialize(obj: T): String

    /**
     * Deserializes the given string.
     *
     * @throws SerializationException if the string can't be deserialized
     */
    @Throws(SerializationException::class)
    fun deserialize(string: String): T
}

class SerializationException : Exception()

object IntSerializer : ConfigSerializer<Int> {
    override fun serialize(obj: Int): String = obj.toString()
    @Throws(SerializationException::class)
    override fun deserialize(string: String): Int = string.toIntOrNull()
        ?: throw SerializationException()
}

/**
 * Serializer for files. Will not check for existence on deserialization.
 */
object FileSerializer : ConfigSerializer<File> {

    override fun serialize(obj: File): String {
        return obj.path
    }

    override fun deserialize(string: String): File {
        return File(string)
    }
}
{'fraction_non_alphanumeric': 0.09784324039978959, 'fraction_numerical': 0.0, 'mean_word_length': 3.4027777777777777, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '2563700', 'n_tokens_mistral': 528, 'n_tokens_neox': 520, 'n_words': 146}