use of org.dkpro.lab.task.ParameterSpace in project dkpro-lab by dkpro.
the class BatchTaskTest method testUnresolvable.
@Test(expected = RuntimeException.class)
public void testUnresolvable() throws Exception {
Dimension<String> dim = Dimension.create("param", "1", "2", "3");
ParameterSpace pSpace = new ParameterSpace(dim);
Task task1 = new ExecutableTaskBase() {
@Discriminator
private String param;
@Override
public void execute(TaskContext aContext) throws Exception {
// Nothing to do
}
};
Task task2 = new ExecutableTaskBase() {
@Discriminator
private String param;
@Override
public void execute(TaskContext aContext) throws Exception {
// Nothing to do
}
};
task2.addImport(task1, "DUMMY");
task1.addImport(task2, "DUMMY");
DefaultBatchTask batchTask = new DefaultBatchTask();
batchTask.setParameterSpace(pSpace);
batchTask.addTask(task1);
batchTask.addTask(task2);
Lab.getInstance().run(batchTask);
}
use of org.dkpro.lab.task.ParameterSpace in project dkpro-lab by dkpro.
the class DiscriminatorTest method testMap.
@Test
public void testMap() throws Exception {
Map<String, String> map1 = new HashMap<String, String>();
map1.put("A", "89zsöoibca");
map1.put("243jh1g45", "09z2#3ROj 2r!]9832");
Map<String, String> map2 = new HashMap<String, String>();
map2.put("!&(B§V §= ", "ü 8z9^2g3f9 xy");
map2.put("!&§$ Ü!§$%ø⁄ª¨", "!$§ 240324 #");
Dimension<Map<String, String>> dimMap = Dimension.create("map", map1, map2);
ParameterSpace pSpace = new ParameterSpace(dimMap);
DefaultBatchTask batch = new DefaultBatchTask();
batch.setParameterSpace(pSpace);
batch.addTask(new MapDiscriminatorTask());
Lab.getInstance().run(batch);
}
use of org.dkpro.lab.task.ParameterSpace in project dkpro-lab by dkpro.
the class DiscriminatorTest method testName.
@Test
public void testName() throws Exception {
Dimension<String> dimValues = Dimension.create("val", "1");
DefaultBatchTask batch = new DefaultBatchTask();
batch.setParameterSpace(new ParameterSpace(dimValues));
batch.addTask(new NameDiscriminatorTask());
Lab.getInstance().run(batch);
}
use of org.dkpro.lab.task.ParameterSpace in project dkpro-lab by dkpro.
the class FoldDimensionBundleTest method testFileFold.
@Test
public void testFileFold() {
Dimension<String> baseData = Dimension.create("base", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10");
FoldDimensionBundle<String> foldBundle = new FoldDimensionBundle<String>("fold", baseData, 3);
String expected = "0 - [1, 4, 7, 10] [2, 5, 8, 3, 6, 9]\n" + "1 - [2, 5, 8] [1, 4, 7, 10, 3, 6, 9]\n" + "2 - [3, 6, 9] [1, 4, 7, 10, 2, 5, 8]\n";
StringBuilder actual = new StringBuilder();
int n = 0;
ParameterSpace pSpace = new ParameterSpace(foldBundle);
for (Map<String, Object> config : pSpace) {
actual.append(String.format("%d - %s %s\n", n, config.get("fold_validation"), config.get("fold_training")));
n++;
}
assertEquals(3, n);
assertEquals(3, pSpace.getStepCount());
assertEquals(expected, actual.toString());
}
use of org.dkpro.lab.task.ParameterSpace in project dkpro-lab by dkpro.
the class FoldDimensionBundleTest method testSimpleFold.
@Test
public void testSimpleFold() {
Dimension<String> baseData = Dimension.create("base", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10");
FoldDimensionBundle<String> foldBundle = new FoldDimensionBundle<String>("fold", baseData, 3);
String expected = "0 - [1, 4, 7, 10] [2, 5, 8, 3, 6, 9]\n" + "1 - [2, 5, 8] [1, 4, 7, 10, 3, 6, 9]\n" + "2 - [3, 6, 9] [1, 4, 7, 10, 2, 5, 8]\n";
StringBuilder actual = new StringBuilder();
int n = 0;
ParameterSpace pSpace = new ParameterSpace(foldBundle);
for (Map<String, Object> config : pSpace) {
actual.append(String.format("%d - %s %s\n", n, config.get("fold_validation"), config.get("fold_training")));
n++;
}
assertEquals(3, n);
assertEquals(3, pSpace.getStepCount());
assertEquals(expected, actual.toString());
}
Aggregations