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());
}
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());
}
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());
}
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);
}
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);
}
Aggregations