<commit_before>package kotlinx.html.generate

import kotlinx.html.generate.humanize.*
import java.util.*

object Repository {
    val tags = TreeMap<String, TagInfo>()

    @Suppress("UNCHECKED_CAST")
    val attributeDelegateRequests = TreeSet<AttributeRequest> ({a, b -> // TODO use new API instead to build comparator
        a.type.compareTo(b.type).let { typeComparison ->
            if (typeComparison != 0) typeComparison
            else a.enumTypeName.compareTo(b.enumTypeName).let { enumTypeComparison ->
                if (enumTypeComparison != 0) enumTypeComparison
                else a.options.size.compareTo(b.options.size).let { sizeComparison ->
                    if (sizeComparison != 0) sizeComparison
                    else if (a.options.isEmpty()) 0
                    else a.options.indices.map { a.options[it].asValue.compareTo(b.options[it].asValue) }.firstOrNull() { it != 0 } ?: 0
                }
            }
        }
    })

    val attributeFacades = TreeMap<String, AttributeFacade>()
    val tagGroups = TreeMap<String, TagGroup>()
}

data class AttributeFacade(val name : String, val attributes : List<AttributeInfo>, val required : Set<String>) {
    val attributeNames = attributes.map {it.name}.toSet()
}

data class AttributeEnumValue (
        val realName : String,
        val fieldName : String
)

enum class AttributeType(val classPrefix : String, val typeName : String) {
    STRING("String", "String"),
    STRING_SET("StringSet", "Set<String>"),
    BOOLEAN("Boolean", "Boolean"),
    TICKER("Ticker", "Boolean"),
    ENUM("Enum", "???")
}

interface HasType {
    val type : AttributeType
    val enumTypeName : String
}<commit_msg>Code cleanup: use comparator builder instead of complex comparator lambda<commit_after>package kotlinx.html.generate

import kotlinx.html.generate.humanize.*
import java.util.*

object Repository {
    val tags = TreeMap<String, TagInfo>()

    val attributeDelegateRequests = TreeSet<AttributeRequest> (
            comparator<AttributeRequest> { a, b -> a.type.compareTo(b.type) }
                    .thenComparator { a, b -> a.enumTypeName.compareTo(b.enumTypeName) }
                    .thenComparator { a, b -> a.options.size.compareTo(b.options.size) }
                    .thenComparator { a, b ->
                        a.options.zip(b.options).map { it.first.asValue.compareTo(it.second.asValue) }.firstOrNull { it != 0 } ?: 0
                    }
    )

    val attributeFacades = TreeMap<String, AttributeFacade>()
    val tagGroups = TreeMap<String, TagGroup>()
}

data class AttributeFacade(val name : String, val attributes : List<AttributeInfo>, val required : Set<String>) {
    val attributeNames = attributes.map {it.name}.toSet()
}

data class AttributeEnumValue (
        val realName : String,
        val fieldName : String
)

enum class AttributeType(val classPrefix : String, val typeName : String) {
    STRING("String", "String"),
    STRING_SET("StringSet", "Set<String>"),
    BOOLEAN("Boolean", "Boolean"),
    TICKER("Ticker", "Boolean"),
    ENUM("Enum", "???")
}

interface HasType {
    val type : AttributeType
    val enumTypeName : String
}
{'fraction_non_alphanumeric': 0.12306721363206059, 'fraction_numerical': 0.0025244556642473968, 'mean_word_length': 2.880048959608323, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 26, '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': '226072', 'n_tokens_mistral': 930, 'n_tokens_neox': 907, 'n_words': 216}