<commit_before>package co.stepo.extensions

import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.io.File
import java.math.BigDecimal
import java.math.RoundingMode
import java.nio.charset.Charset
import java.time.LocalDate
import java.util.*
import java.util.Collection
import java.util.stream.Collectors
import kotlin.reflect.companionObjectInstance

fun <T> nullIfException(block: () -> T?): T? {
    return try {
        block()
    } catch (e: Exception) {
        null
    }
}

fun Number.padStart(length: Int, padChar: Char = ' '): String = this.toString().padStart(length, padChar)
fun Number.padEnd(length: Int, padChar: Char = ' '): String = this.toString().padEnd(length, padChar)

val Double.point2: String get() {
    if (this.isInfinite() || this.isNaN()) return this.toString()
    return BigDecimal.valueOf(this).setScale(2, RoundingMode.HALF_UP).toPlainString()
}

//
// Collection
//

inline fun <T> Iterable<T>.peek(action: (T) -> Unit): List<T> {
    this.forEach(action)
    return this.toList()
}

inline fun <T> Iterable<T>.parallelForEach(crossinline action: (T) -> Unit): Unit {
    val collection = this as Collection<T>
    return collection.parallelStream().forEach { action(it) }
}

inline fun <T, R> Iterable<T>.parallelMap(crossinline transform: (T) -> R): List<R> {
    val collection = this as Collection<T>
    return collection.parallelStream().map { transform(it) }.collect(Collectors.toList<R>())
}
<commit_msg>remove utility function<commit_after>package co.stepo.extensions

import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.io.File
import java.math.BigDecimal
import java.math.RoundingMode
import java.nio.charset.Charset
import java.time.LocalDate
import java.util.*
import java.util.Collection
import java.util.stream.Collectors
import kotlin.reflect.companionObjectInstance

fun Number.padStart(length: Int, padChar: Char = ' '): String = this.toString().padStart(length, padChar)
fun Number.padEnd(length: Int, padChar: Char = ' '): String = this.toString().padEnd(length, padChar)

val Double.point2: String get() {
    if (this.isInfinite() || this.isNaN()) return this.toString()
    return BigDecimal.valueOf(this).setScale(2, RoundingMode.HALF_UP).toPlainString()
}

//
// Collection
//

inline fun <T> Iterable<T>.peek(action: (T) -> Unit): List<T> {
    this.forEach(action)
    return this.toList()
}

inline fun <T> Iterable<T>.parallelForEach(crossinline action: (T) -> Unit): Unit {
    val collection = this as Collection<T>
    return collection.parallelStream().forEach { action(it) }
}

inline fun <T, R> Iterable<T>.parallelMap(crossinline transform: (T) -> R): List<R> {
    val collection = this as Collection<T>
    return collection.parallelStream().map { transform(it) }.collect(Collectors.toList<R>())
}

{'fraction_non_alphanumeric': 0.14255091103965703, 'fraction_numerical': 0.0028581636298678098, 'mean_word_length': 4.588822355289421, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 33, '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': '5007732', 'n_tokens_mistral': 910, 'n_tokens_neox': 905, 'n_words': 208}