Search in sources :

Example 6 with ExecutableTaskBase

use of org.dkpro.lab.task.impl.ExecutableTaskBase in project dkpro-tc by dkpro.

the class DKProTcShallowTestTask method initialize.

@Override
public void initialize(TaskContext aContext) {
    super.initialize(aContext);
    TcShallowLearningAdapter adapter = (TcShallowLearningAdapter) classArgs.get(0);
    ExecutableTaskBase testTask = adapter.getTestTask();
    testTask.addReport(adapter.getOutcomeIdReportClass());
    Class<? extends ReportBase> baselineIdReportClass = adapter.getMajorityClassBaselineIdReportClass();
    if (baselineIdReportClass != null) {
        testTask.addReport(baselineIdReportClass);
    }
    Class<? extends ReportBase> randomBaselineIdReportClass = adapter.getRandomBaselineIdReportClass();
    if (randomBaselineIdReportClass != null) {
        testTask.addReport(randomBaselineIdReportClass);
    }
    if (reports != null) {
        for (ReportBase b : reports) {
            testTask.addReport(b);
        }
    }
    testTask.addImport(featuresTrainTask, ExtractFeaturesTask.OUTPUT_KEY, Constants.TEST_TASK_INPUT_KEY_TRAINING_DATA);
    testTask.addImport(featuresTestTask, ExtractFeaturesTask.OUTPUT_KEY, Constants.TEST_TASK_INPUT_KEY_TEST_DATA);
    testTask.addImport(collectionTask, OutcomeCollectionTask.OUTPUT_KEY, Constants.OUTCOMES_INPUT_KEY);
    testTask.setAttribute(TC_TASK_TYPE, TcTaskType.MACHINE_LEARNING_ADAPTER.toString());
    testTask.setType(testTask.getType() + "-" + experimentName);
    deleteOldTaskSetNewOne(testTask);
}
Also used : ReportBase(org.dkpro.lab.reporting.ReportBase) TcShallowLearningAdapter(org.dkpro.tc.core.ml.TcShallowLearningAdapter) ExecutableTaskBase(org.dkpro.lab.task.impl.ExecutableTaskBase)

Example 7 with ExecutableTaskBase

use of org.dkpro.lab.task.impl.ExecutableTaskBase in project dkpro-lab by dkpro.

the class BatchTaskTest method importTest.

@Test(expected = RuntimeException.class)
public void importTest() throws Exception {
    Task producer = new ExecutableTaskBase() {

        @Override
        public void execute(TaskContext aContext) throws Exception {
            System.out.println("Running producer");
            Properties data = new Properties();
            data.setProperty("key", "value");
            aContext.storeBinary("DATA", new PropertiesAdapter(data));
        }
    };
    Task consumer = new ExecutableTaskBase() {

        @Override
        public void execute(TaskContext aContext) throws Exception {
            System.out.println("Running consumer");
            Properties data = new Properties();
            aContext.retrieveBinary("DATA", new PropertiesAdapter(data));
            Assert.assertEquals(data.getProperty("key"), "value");
        }
    };
    consumer.addImport(producer, "DATA1", "DATA");
    DefaultBatchTask batch = new DefaultBatchTask();
    batch.addTask(producer);
    batch.addTask(consumer);
    Lab.getInstance().run(batch);
}
Also used : Task(org.dkpro.lab.task.Task) DefaultBatchTask(org.dkpro.lab.task.impl.DefaultBatchTask) TaskContext(org.dkpro.lab.engine.TaskContext) PropertiesAdapter(org.dkpro.lab.storage.impl.PropertiesAdapter) ExecutableTaskBase(org.dkpro.lab.task.impl.ExecutableTaskBase) Properties(java.util.Properties) DefaultBatchTask(org.dkpro.lab.task.impl.DefaultBatchTask) Test(org.junit.Test)

Example 8 with ExecutableTaskBase

use of org.dkpro.lab.task.impl.ExecutableTaskBase 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);
}
Also used : Task(org.dkpro.lab.task.Task) DefaultBatchTask(org.dkpro.lab.task.impl.DefaultBatchTask) TaskContext(org.dkpro.lab.engine.TaskContext) ParameterSpace(org.dkpro.lab.task.ParameterSpace) ExecutableTaskBase(org.dkpro.lab.task.impl.ExecutableTaskBase) DefaultBatchTask(org.dkpro.lab.task.impl.DefaultBatchTask) Test(org.junit.Test)

Example 9 with ExecutableTaskBase

use of org.dkpro.lab.task.impl.ExecutableTaskBase in project dkpro-lab by dkpro.

the class TaskBaseTest method settingDiscriminatorsNotAllowedAfterTaskRan.

@Test(expected = IllegalStateException.class)
public void settingDiscriminatorsNotAllowedAfterTaskRan() throws Exception {
    Task consumer = new ExecutableTaskBase() {

        @Override
        public void execute(TaskContext aContext) throws Exception {
        // do nothing
        }
    };
    // this should still work
    consumer.setDescriminator("DUMMY_KEY", "123");
    DefaultBatchTask batch = new DefaultBatchTask();
    batch.addTask(consumer);
    Lab.getInstance().run(batch);
    // Task did run - no modification allowed
    consumer.setDescriminator("DUMMY_KEY_2", "1234");
}
Also used : DefaultBatchTask(org.dkpro.lab.task.impl.DefaultBatchTask) TaskContext(org.dkpro.lab.engine.TaskContext) ExecutableTaskBase(org.dkpro.lab.task.impl.ExecutableTaskBase) DefaultBatchTask(org.dkpro.lab.task.impl.DefaultBatchTask) Test(org.junit.Test)

Example 10 with ExecutableTaskBase

use of org.dkpro.lab.task.impl.ExecutableTaskBase in project dkpro-lab by dkpro.

the class TaskBaseTest method settingAttributesNotAllowedAfterTaskRan.

@Test(expected = IllegalStateException.class)
public void settingAttributesNotAllowedAfterTaskRan() throws Exception {
    Task consumer = new ExecutableTaskBase() {

        @Override
        public void execute(TaskContext aContext) throws Exception {
        // do nothing
        }
    };
    // this should still work
    consumer.setAttribute("DUMMY_KEY", "123");
    DefaultBatchTask batch = new DefaultBatchTask();
    batch.addTask(consumer);
    Lab.getInstance().run(batch);
    // Task did run - no modification allowed
    consumer.setAttribute("DUMMY_KEY_2", "1234");
}
Also used : DefaultBatchTask(org.dkpro.lab.task.impl.DefaultBatchTask) TaskContext(org.dkpro.lab.engine.TaskContext) ExecutableTaskBase(org.dkpro.lab.task.impl.ExecutableTaskBase) DefaultBatchTask(org.dkpro.lab.task.impl.DefaultBatchTask) Test(org.junit.Test)

Aggregations

ExecutableTaskBase (org.dkpro.lab.task.impl.ExecutableTaskBase)11 DefaultBatchTask (org.dkpro.lab.task.impl.DefaultBatchTask)10 Test (org.junit.Test)10 TaskContext (org.dkpro.lab.engine.TaskContext)9 Task (org.dkpro.lab.task.Task)6 ParameterSpace (org.dkpro.lab.task.ParameterSpace)4 File (java.io.File)3 ImsCwbWriter (de.tudarmstadt.ukp.dkpro.core.io.imscwb.ImsCwbWriter)2 XmiWriter (de.tudarmstadt.ukp.dkpro.core.io.xmi.XmiWriter)2 SnowballStemmer (de.tudarmstadt.ukp.dkpro.core.snowball.SnowballStemmer)2 BreakIteratorSegmenter (de.tudarmstadt.ukp.dkpro.core.tokit.BreakIteratorSegmenter)2 Properties (java.util.Properties)2 ExamplePosAnnotator (org.dkpro.lab.ml.example.ExamplePosAnnotator)2 PropertiesAdapter (org.dkpro.lab.storage.impl.PropertiesAdapter)2 UimaTaskBase (org.dkpro.lab.uima.task.impl.UimaTaskBase)2 Collection (java.util.Collection)1 ReportBase (org.dkpro.lab.reporting.ReportBase)1 FileSystemStorageService (org.dkpro.lab.storage.filesystem.FileSystemStorageService)1 FoldDimensionBundle (org.dkpro.lab.task.impl.FoldDimensionBundle)1 TcShallowLearningAdapter (org.dkpro.tc.core.ml.TcShallowLearningAdapter)1