Search in sources :

Example 61 with ParameterSpace

use of org.dkpro.lab.task.ParameterSpace in project dkpro-lab by dkpro.

the class ParameterSpaceTest method test.

@Test
public void test() {
    Dimension<String> letters = Dimension.create("letters", "a", "b", "c");
    Dimension<Integer> numbers = Dimension.create("numbers", 1, 2);
    Dimension<Character> symbols = Dimension.create("symbols", '!', '&');
    int n = 0;
    ParameterSpace pSpace = new ParameterSpace(letters, numbers, symbols);
    for (@SuppressWarnings("unused") Map<String, Object> config : pSpace) {
        n++;
    }
    assertEquals(3 * 2 * 2, n);
    assertEquals((3 * 2 * 2), pSpace.getStepCount());
}
Also used : ParameterSpace(org.dkpro.lab.task.ParameterSpace) Constraint(org.dkpro.lab.task.Constraint) Test(org.junit.Test)

Example 62 with ParameterSpace

use of org.dkpro.lab.task.ParameterSpace in project dkpro-lab by dkpro.

the class ParameterSpaceTest method testZeroSizeDimension.

@Test
public void testZeroSizeDimension() {
    Dimension<String> letters = Dimension.create("letters", "a", "b", "c");
    Dimension<Integer> numbers = Dimension.create("numbers");
    int n = 0;
    ParameterSpace pSpace = new ParameterSpace(letters, numbers);
    for (@SuppressWarnings("unused") Map<String, Object> config : pSpace) {
        n++;
    }
    assertEquals(3, n);
    assertEquals(3, pSpace.getStepCount());
}
Also used : ParameterSpace(org.dkpro.lab.task.ParameterSpace) Constraint(org.dkpro.lab.task.Constraint) Test(org.junit.Test)

Example 63 with ParameterSpace

use of org.dkpro.lab.task.ParameterSpace in project dkpro-lab by dkpro.

the class ParameterSpaceTest method testWithConstraint.

@Test
public void testWithConstraint() {
    Dimension<String> letters = Dimension.create("letters", "a", "b", "c");
    Dimension<Integer> numbers = Dimension.create("numbers", 1, 2);
    Dimension<Character> symbols = Dimension.create("symbols", '!', '&');
    int n = 0;
    ParameterSpace pSpace = new ParameterSpace(letters, numbers, symbols);
    pSpace.addConstraint(new Constraint() {

        @Override
        public boolean isValid(Map<String, Object> aConfiguration) {
            // a implies 1
            return !aConfiguration.get("letters").equals("a") || aConfiguration.get("symbols").equals('!');
        }
    });
    for (Map<String, Object> config : pSpace) {
        System.out.println(config);
        if ("a".equals(config.get("letters")) && !config.get("symbols").equals('!')) {
            fail();
        }
        n++;
    }
    assertEquals((3 * 2 * 2) - 2, n);
    assertEquals((3 * 2 * 2), pSpace.getStepCount());
}
Also used : ParameterSpace(org.dkpro.lab.task.ParameterSpace) Constraint(org.dkpro.lab.task.Constraint) Constraint(org.dkpro.lab.task.Constraint) Test(org.junit.Test)

Example 64 with ParameterSpace

use of org.dkpro.lab.task.ParameterSpace in project dkpro-lab by dkpro.

the class ConversionServiceTest method testDiscriminationWithoutConversionServiceOverride.

@Test
public void testDiscriminationWithoutConversionServiceOverride() throws Exception {
    Integer integer = new Integer(3);
    ParameterSpace ps = new ParameterSpace(Dimension.create(KEY, integer));
    DefaultBatchTask batch = new DefaultBatchTask();
    batch.setParameterSpace(ps);
    batch.addTask(consumer);
    Lab instance = Lab.newInstance(Lab.DEFAULT_CONTEXT);
    instance.run(batch);
    assertEquals("3", discriminatorText);
}
Also used : ParameterSpace(org.dkpro.lab.task.ParameterSpace) Lab(org.dkpro.lab.Lab) DefaultBatchTask(org.dkpro.lab.task.impl.DefaultBatchTask) Test(org.junit.Test)

Example 65 with ParameterSpace

use of org.dkpro.lab.task.ParameterSpace in project dkpro-lab by dkpro.

the class ConversionServiceTest method testDiscriminationWithConversionServiceOverride.

@Test
public void testDiscriminationWithConversionServiceOverride() throws Exception {
    Integer integer = new Integer(3);
    ParameterSpace ps = new ParameterSpace(Dimension.create(KEY, integer));
    DefaultBatchTask batch = new DefaultBatchTask();
    batch.setParameterSpace(ps);
    batch.addTask(consumer);
    Lab instance = Lab.newInstance(Lab.DEFAULT_CONTEXT);
    // we register an alternative text for the integer value which should be used instead of the
    // default of converting the numerical value to string
    instance.getConversionService().registerDiscriminable(integer, "three");
    instance.run(batch);
    assertEquals("three", discriminatorText);
}
Also used : ParameterSpace(org.dkpro.lab.task.ParameterSpace) Lab(org.dkpro.lab.Lab) DefaultBatchTask(org.dkpro.lab.task.impl.DefaultBatchTask) Test(org.junit.Test)

Aggregations

ParameterSpace (org.dkpro.lab.task.ParameterSpace)130 HashMap (java.util.HashMap)60 CollectionReaderDescription (org.apache.uima.collection.CollectionReaderDescription)51 Map (java.util.Map)45 Test (org.junit.Test)44 TcFeatureSet (org.dkpro.tc.api.features.TcFeatureSet)42 File (java.io.File)26 WekaAdapter (org.dkpro.tc.ml.weka.WekaAdapter)21 DefaultBatchTask (org.dkpro.lab.task.impl.DefaultBatchTask)12 ArrayList (java.util.ArrayList)10 LiblinearAdapter (org.dkpro.tc.ml.liblinear.LiblinearAdapter)9 NaiveBayes (weka.classifiers.bayes.NaiveBayes)9 TaskContext (org.dkpro.lab.engine.TaskContext)7 CrfSuiteAdapter (org.dkpro.tc.ml.crfsuite.CrfSuiteAdapter)7 LibsvmAdapter (org.dkpro.tc.ml.libsvm.LibsvmAdapter)7 List (java.util.List)6 XgboostAdapter (org.dkpro.tc.ml.xgboost.XgboostAdapter)6 FoldDimensionBundle (org.dkpro.lab.task.impl.FoldDimensionBundle)5 SMO (weka.classifiers.functions.SMO)5 Task (org.dkpro.lab.task.Task)4