use of org.dkpro.lab.storage.filesystem.FileSystemStorageService in project dkpro-lab by dkpro.
the class FoldDimensionBundleTest method testFoldInjection.
@Test
public void testFoldInjection() throws Exception {
File repo = new File("target/repository/" + getClass().getSimpleName() + "/" + name.getMethodName());
FileUtils.deleteDirectory(repo);
repo.mkdirs();
((FileSystemStorageService) Lab.getInstance().getStorageService()).setStorageRoot(repo);
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";
ParameterSpace pSpace = new ParameterSpace(foldBundle);
final StringBuilder actual = new StringBuilder();
Task testTask = new ExecutableTaskBase() {
int n = 0;
@Discriminator
Collection<String> fold_validation;
@Discriminator
Collection<String> fold_training;
@Override
public void execute(TaskContext aContext) throws Exception {
System.out.printf("%d training : %s\n", n, fold_training);
System.out.printf("%d validation: %s\n", n, fold_validation);
actual.append(String.format("%d - %s %s\n", n, fold_validation, fold_training));
n++;
}
};
DefaultBatchTask batchTask = new DefaultBatchTask();
batchTask.setParameterSpace(pSpace);
batchTask.addTask(testTask);
Lab.getInstance().run(batchTask);
assertEquals(3, pSpace.getStepCount());
assertEquals(expected, actual.toString());
}
use of org.dkpro.lab.storage.filesystem.FileSystemStorageService in project dkpro-lab by dkpro.
the class PosExampleCrf method clean.
/**
* This is a hack to change the repository to a path inside this project.Normally you should
* set the environment variable DKPRO_HOME before using the Lab.
*/
public void clean() throws Exception {
System.setProperty("DKPRO_HOME", new File("target").getAbsolutePath());
File repo = new File("target/repository");
FileUtils.deleteDirectory(repo);
repo.mkdirs();
((FileSystemStorageService) Lab.getInstance().getStorageService()).setStorageRoot(repo);
}
use of org.dkpro.lab.storage.filesystem.FileSystemStorageService in project dkpro-lab by dkpro.
the class PosExampleMaxEnt method clean.
/**
* This is a hack to change the repository to a path inside this project.Normally you should
* set the environment variable DKPRO_HOME before using the Lab.
*/
public void clean() throws Exception {
System.setProperty("DKPRO_HOME", new File("target").getAbsolutePath());
File repo = new File("target/repository");
FileUtils.deleteDirectory(repo);
repo.mkdirs();
((FileSystemStorageService) Lab.getInstance().getStorageService()).setStorageRoot(repo);
}
use of org.dkpro.lab.storage.filesystem.FileSystemStorageService in project dkpro-lab by dkpro.
the class SimpleExecutionEngineTest method testInit.
@Test
public void testInit() throws Exception {
File repo = new File("target/repository");
FileUtils.deleteDirectory(repo);
((FileSystemStorageService) storageService).setStorageRoot(repo);
assertNotNull(executionService);
assertNotNull(contextFactory);
TypeSystemDescription tsd = createTypeSystemDescription(new String[0]);
AnalysisEngineDescription desc = createEngineDescription(DummyAE.class, tsd);
DefaultUimaTask cfg = new DefaultUimaTask();
cfg.setReaderDescription(createReaderDescription(TestReader.class, tsd));
cfg.setAnalysisEngineDescription(desc);
TaskExecutionEngine runner = executionService.createEngine(cfg);
String uuid = runner.run(cfg);
System.out.println("=== Experiments in repository ===");
List<TaskContextMetadata> experiments = storageService.getContexts();
for (TaskContextMetadata e : experiments) {
System.out.println(e);
}
final StringBuilder sb = new StringBuilder();
storageService.retrieveBinary(uuid, "test", new StreamReader() {
@Override
public void read(InputStream aInputStream) throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
Util.shoveAndClose(aInputStream, bos);
sb.append(new String(bos.toByteArray(), "UTF-8"));
}
});
assertEquals("works", sb.toString());
}
use of org.dkpro.lab.storage.filesystem.FileSystemStorageService in project dkpro-lab by dkpro.
the class UimaAsExecutionEngineTest method testInit.
@Test
public void testInit() throws Exception {
File repo = new File("target/repository");
FileUtils.deleteQuietly(repo);
((FileSystemStorageService) storageService).setStorageRoot(repo);
assertNotNull(executionService);
assertNotNull(contextFactory);
AnalysisEngineDescription desc = createEngineDescription(DummyAE.class);
DefaultUimaTask cfg = new DefaultUimaTask();
cfg.setReaderDescription(createReaderDescription(TestReader.class));
cfg.setAnalysisEngineDescription(desc);
TaskExecutionEngine runner = executionService.createEngine(cfg);
String uuid = runner.run(cfg);
System.out.println("=== Experiments in repository ===");
List<TaskContextMetadata> experiments = storageService.getContexts();
for (TaskContextMetadata e : experiments) {
System.out.println(e);
}
final StringBuilder sb = new StringBuilder();
storageService.retrieveBinary(uuid, "test", new StreamReader() {
@Override
public void read(InputStream aInputStream) throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
Util.shoveAndClose(aInputStream, bos);
sb.append(new String(bos.toByteArray(), "UTF-8"));
}
});
assertEquals("works", sb.toString());
}
Aggregations