Search in sources :

Example 16 with DefaultBatchTask

use of org.dkpro.lab.task.impl.DefaultBatchTask 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)

Example 17 with DefaultBatchTask

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

the class MultiThreadBatchTaskTest method importTest.

@Test(expected = UnresolvedImportException.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();
    // BatchTask batch = new BatchTask();
    batch.addTask(producer);
    batch.addTask(consumer);
    Lab.getInstance().run(batch);
}
Also used : 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 18 with DefaultBatchTask

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

the class MultiThreadTaskPerformanceTest method setup.

@Before
public void setup() {
    File path = new File("target/repository/" + getClass().getSimpleName() + "/" + name.getMethodName());
    System.setProperty("DKPRO_HOME", path.getAbsolutePath());
    FileUtils.deleteQuietly(path);
    // batchTask = new BatchTask();
    batchTask = new DefaultBatchTask();
}
Also used : File(java.io.File) DefaultBatchTask(org.dkpro.lab.task.impl.DefaultBatchTask) Before(org.junit.Before)

Example 19 with DefaultBatchTask

use of org.dkpro.lab.task.impl.DefaultBatchTask 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 20 with DefaultBatchTask

use of org.dkpro.lab.task.impl.DefaultBatchTask 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

DefaultBatchTask (org.dkpro.lab.task.impl.DefaultBatchTask)20 Test (org.junit.Test)17 ParameterSpace (org.dkpro.lab.task.ParameterSpace)12 TaskContext (org.dkpro.lab.engine.TaskContext)11 ExecutableTaskBase (org.dkpro.lab.task.impl.ExecutableTaskBase)9 File (java.io.File)6 Map (java.util.Map)5 Task (org.dkpro.lab.task.Task)5 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 Lab (org.dkpro.lab.Lab)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 TextClassificationException (org.dkpro.tc.api.exception.TextClassificationException)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1