<commit_before>package org.anc.lapps.dsl

import org.lappsgrid.client.DataSourceClient
import org.lappsgrid.client.ServiceClient
import org.codehaus.groovy.control.CompilerConfiguration
import org.codehaus.groovy.control.customizers.ImportCustomizer

/**
 * @author <NAME>
 */
class LappsDsl {
    static final String EXTENSION = ".lsd"

    Set<String> included = new HashSet<String>()
    File parentDir
    Binding bindings = new Binding()

    void run(File file, args) {
        parentDir = file.parentFile
        run(file.text, args)
    }

    ClassLoader getLoader() {
        ClassLoader loader = Thread.currentThread().contextClassLoader;
        if (loader == null) {
            loader = this.class.classLoader
        }
        return loader
    }

    CompilerConfiguration getCompilerConfiguration() {
        ImportCustomizer customizer = new ImportCustomizer()
        def packages = [
                'org.lappsgrid.api',
                'org.lappsgrid.core',
                'org.lappsgrid.client',
                'org.lappsgrid.discriminator',
                'org.lappsgrid.serialization',
                'org.lappsgrid.serialization.lif',
                'org.lappsgrid.serialization.datasource',
                'org.lappsgrid.metadata',

                'org.anc.lapps.pipeline',
                'org.anc.io',
                'org.anc.util',
                'org.anc.json.validator',
                'org.anc.json.transform'
        ]
        packages.each {
            customizer.addStarImports(it)
        }
        customizer.addStaticImport('org.lappsgrid.discriminator.Distriminators', 'Uri')
        //customizer.addStaticImport('org.lappsgrid.discriminator.Distriminators', 'Alias')

        CompilerConfiguration configuration = new CompilerConfiguration()
        configuration.addCompilationCustomizers(customizer)
        return configuration
    }

    void interactiveMode(args) {
        TextDevice io = TextDevice.create()
        ClassLoader loader = getLoader()
        CompilerConfiguration configuration = getCompilerConfiguration()
        GroovyShell shell = new GroovyShell(loader, bindings, configuration)
        def params = [:]
        if (args != null && args.size() > 0) {
            // Parse any command line arguements into a HashMap that will
            // be passed in to the user's script.<commit_msg>Fixed typo in Discriminators import.<commit_after>package org.anc.lapps.dsl

import org.lappsgrid.client.DataSourceClient
import org.lappsgrid.client.ServiceClient
import org.codehaus.groovy.control.CompilerConfiguration
import org.codehaus.groovy.control.customizers.ImportCustomizer

/**
 * @author <NAME>
 */
class LappsDsl {
    static final String EXTENSION = ".lsd"

    Set<String> included = new HashSet<String>()
    File parentDir
    Binding bindings = new Binding()

    void run(File file, args) {
        parentDir = file.parentFile
        run(file.text, args)
    }

    ClassLoader getLoader() {
        ClassLoader loader = Thread.currentThread().contextClassLoader;
        if (loader == null) {
            loader = this.class.classLoader
        }
        return loader
    }

    CompilerConfiguration getCompilerConfiguration() {
        ImportCustomizer customizer = new ImportCustomizer()
        def packages = [
                'org.lappsgrid.api',
                'org.lappsgrid.core',
                'org.lappsgrid.client',
                'org.lappsgrid.discriminator',
                'org.lappsgrid.serialization',
                'org.lappsgrid.serialization.lif',
                'org.lappsgrid.serialization.datasource',
                'org.lappsgrid.metadata',

                'org.anc.lapps.pipeline',
                'org.anc.io',
                'org.anc.util',
                'org.anc.json.validator',
                'org.anc.json.transform'
        ]
        packages.each {
            customizer.addStarImports(it)
        }
        customizer.addStaticImport('org.lappsgrid.discriminator.Discriminators', 'Uri')
        //customizer.addStaticImport('org.lappsgrid.discriminator.Distriminators', 'Alias')

        CompilerConfiguration configuration = new CompilerConfiguration()
        configuration.addCompilationCustomizers(customizer)
        return configuration
    }

    void interactiveMode(args) {
        TextDevice io = TextDevice.create()
        ClassLoader loader = getLoader()
        CompilerConfiguration configuration = getCompilerConfiguration()
        GroovyShell shell = new GroovyShell(loader, bindings, configuration)
        def params = [:]
        if (args != null && args.size() > 0) {
            // Parse any command line arguements into a HashMap that will
            // be passed in to the user's script.
{'fraction_non_alphanumeric': 0.09661123973900232, 'fraction_numerical': 0.0004209640075773521, 'mean_word_length': 2.254794520547945, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '4933067', 'n_tokens_mistral': 1311, 'n_tokens_neox': 1234, 'n_words': 251}