<commit_before>package com.github.gfx.ribbonizer
import com.android.build.gradle.api.ApplicationVariant
import com.android.builder.model.SourceProvider
import groovy.transform.CompileStatic
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.TaskAction

@CompileStatic
class RibbonizerTask extends DefaultTask {
    static final String NAME = "ribbonize"

    ApplicationVariant variant
    File outputDir

    List<Ribbonizer.Filter> filters = [new GrayScaleFilter() as Ribbonizer.Filter]

    @TaskAction
    public void run() {
        if (filters.size() == 0) {
            return;
        }

        def t0 = System.currentTimeMillis()

        def extension = project.extensions.getByType(RibbonizerExtension)

        variant.sourceSets.forEach { SourceProvider sourceSet ->
            sourceSet.resDirectories.forEach { File resDir ->
                if (resDir == outputDir) {
                    return
                }

                extension.iconNames.forEach { String name ->
                    info "process $name in $resDir"

                    project.fileTree(
                            dir: resDir,
                            includes: [
                                    "drawable*/${name}.png",
                                    "mipmap*/${name}.png",
                            ]
                    ).forEach { File inputFile ->
                        def basename = inputFile.name
                        def resType = inputFile.parentFile.name
                        def outputFile = new File(outputDir, "${resType}/${basename}")
                        outputFile.parentFile.mkdirs()
                        def ribbonizer = new Ribbonizer(inputFile, outputFile)
                        ribbonizer.process(filters)
                        ribbonizer.save()
                    }
                }
            }
        }

        info("${this.name} ${System.currentTimeMillis() - t0}ms")
    }

    public void info(String message) {
        project.logger.info("[$name] $message")
    }
}<commit_msg>skip process if generated files aready exist<commit_after>package com.github.gfx.ribbonizer
import com.android.build.gradle.api.ApplicationVariant
import com.android.builder.model.SourceProvider
import groovy.transform.CompileStatic
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction

@CompileStatic
class RibbonizerTask extends DefaultTask {
    static final String NAME = "ribbonize"

    ApplicationVariant variant

    @OutputDirectory
    File outputDir

    List<Ribbonizer.Filter> filters = [new GrayScaleFilter() as Ribbonizer.Filter]

    @TaskAction
    public void run() {
        if (filters.size() == 0) {
            return;
        }

        def t0 = System.currentTimeMillis()

        def extension = project.extensions.getByType(RibbonizerExtension)

        variant.sourceSets.forEach { SourceProvider sourceSet ->
            sourceSet.resDirectories.forEach { File resDir ->
                if (resDir == outputDir) {
                    return
                }

                extension.iconNames.forEach { String name ->
                    info "process $name in $resDir"

                    project.fileTree(
                            dir: resDir,
                            includes: [
                                    "drawable*/${name}.png",
                                    "mipmap*/${name}.png",
                            ]
                    ).forEach { File inputFile ->
                        def basename = inputFile.name
                        def resType = inputFile.parentFile.name
                        def outputFile = new File(outputDir, "${resType}/${basename}")
                        outputFile.parentFile.mkdirs()

                        def ribbonizer = new Ribbonizer(inputFile, outputFile)
                        ribbonizer.process(filters)
                        ribbonizer.save()
                    }
                }
            }
        }

        info("${this.name} ${System.currentTimeMillis() - t0}ms")
    }

    public void info(String message) {
        project.logger.info("[$name] $message")
    }
}
{'fraction_non_alphanumeric': 0.08824928639391057, 'fraction_numerical': 0.0014272121788772598, 'mean_word_length': 1.5149521531100478, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5832923', 'n_tokens_mistral': 1078, 'n_tokens_neox': 997, 'n_words': 211}