public static ResourceHandle newInheritHandle(String resource) { return new ResourceHandle(HandleType.INHERIT, resource); }
public BaseExperimentBuilder(String experimentUuid, String resource, TypeSystemDescription typeSystem) throws Exception { this.typeSystem = typeSystem; this.experimentUuid = experimentUuid; this.configuration = ConfigurationLoader.load(resource); this.persistence = newPersistenceProvider(configuration); insertExperiment(configuration, resource); }
public AsyncDriver(String resource, String uuid, OpMode op) throws Exception { this.opMode = op; this.localConfig = ConfigurationLoader.load(resource); if (opMode == OpMode.PRODUCER || opMode == OpMode.REPORT) { resource += "-producer"; this.config = ConfigurationLoader.load(resource); } else { resource += "-consumer"; this.config = ConfigurationLoader.load(resource); } TypeSystemDescription typeSystem = TypeSystemDescriptionFactory.createTypeSystemDescription(); this.builder = new BaseExperimentBuilder(uuid, resource, typeSystem); this.asyncConfig = builder.initializeResource(config, "async-configuration", AsyncConfiguration.class); }
public ECDDriver(String resource, String uuid) throws Exception { TypeSystemDescription typeSystem = TypeSystemDescriptionFactory.createTypeSystemDescription(); this.builder = new BaseExperimentBuilder(uuid, resource, typeSystem); this.config = builder.getConfiguration(); }
public AdHocDriver(ExperimentBuilder builder) throws Exception { this.config = builder.getConfiguration(); this.builder = builder; System.out.println("Experiment UUID: " + builder.getExperimentUuid()); }
public static <C> Class<? extends C> loadFromClassOrInherit(ResourceHandle resource, Class<C> ifaceClass, Map<String, Object> tuples) throws Exception { if (resource.getType() == HandleType.CLASS) { return Class.forName(resource.resource).asSubclass(ifaceClass); } else { if (resource.getType() == HandleType.INHERIT) { AnyObject yaml = ConfigurationLoader.load(resource.resource); return getFromClassOrInherit(yaml, ifaceClass, tuples); } else { throw new IllegalArgumentException( "Illegal experiment descriptor, must contain one node of type <class> or <inherit>"); } } }
private void insertExperiment(AnyObject config, String resource) throws Exception { AnyObject experiment = config.getAnyObject("configuration"); String name = experiment.getString("name"); String author = experiment.getString("author"); persistence.insertExperiment(getExperimentUuid(), name, author, ConfigurationLoader.getString(resource), resource); }
@Override public void initialize(UimaContext context) throws ResourceInitializationException { Object listenerNames = (Object) context.getConfigParameterValue("listeners"); if (listenerNames != null) { listeners = BaseExperimentBuilder.createResourceList(listenerNames, TraceListener.class); } Object experimentListenerNames = context.getConfigParameterValue("experiment-listeners"); if (experimentListenerNames != null) { this.experimentListeners = BaseExperimentBuilder.createResourceList(experimentListenerNames, ExperimentListener.class); } }
public static ResourceHandle newHandle(String type, String resource) { try { return new ResourceHandle(HandleType.valueOf(type.toUpperCase()), resource); } catch (Exception e) { throw new IllegalArgumentException( "Illegal experiment descriptor, must contain one node of type <class> or <inherit>"); } }
@Override public AnalysisEngine buildPipeline(AnyObject config, String pipeline, int stageId) throws Exception { try { return buildPipeline(config, pipeline, stageId, null, true); } catch (Exception e) { throw new ResourceInitializationException( ResourceInitializationException.ERROR_INITIALIZING_FROM_DESCRIPTOR, new Object[] { pipeline, config }, e); } }
public static HandleType getInstance(String value) { return HandleType.valueOf(value.toUpperCase()); } }
private static ResourceHandle buildHandleFromString(String name) { String[] values = name.split("!"); return ResourceHandle.newHandle(values[0], values[1]); }
@Override public String toString() { return String.format("%s[%s]", type.toString().toLowerCase(), resource); } }
private void initDecorators() { nextInput = 0; String decoratorsNames = (String) getConfigParameterValue("decorators"); if (decoratorsNames != null) { this.decorators = BaseExperimentBuilder.createAnnotators(decoratorsNames); } }
@Override public void close() throws IOException { persistence.updateExperimentMeta(getUUID(), count, topics); }
private AnalysisEngineDescription buildPipeline(int stageId, Iterable<AnyObject> pipeline, FlowControllerDescription fcd) throws Exception { AggregateBuilder builder = new AggregateBuilder(null, null, fcd); int phase = 1; for (AnyObject aeDescription : pipeline) { AnalysisEngineDescription description = buildComponent(stageId, phase, aeDescription); builder.add(description); phase++; } return builder.createAggregateDescription(); }
@Override public void initialize(UimaContext context) throws ResourceInitializationException { Object aggregatorNames = context.getConfigParameterValue("aggregators"); if (aggregatorNames != null) { this.aggregators = BaseExperimentBuilder.createResourceList(aggregatorNames, EvaluationAggregator.class); } }
public static ResourceHandle newHandle(HandleType type, String resource) { return new ResourceHandle(type, resource); }
@Override public AnalysisEngine buildPostProcess(AnyObject config, String pipeline, int stageId) throws Exception { try { return buildPipeline(config, pipeline, stageId, null, false); } catch (Exception e) { throw new ResourceInitializationException( ResourceInitializationException.ERROR_INITIALIZING_FROM_DESCRIPTOR, new Object[] { pipeline, config }, e); } }
@Override public void initialize(UimaContext context) throws ResourceInitializationException { Object builderNames = (Object) context.getConfigParameterValue("builders"); if (builderNames != null) { this.builders = BaseExperimentBuilder.createResourceList(builderNames, ReportComponentBuilder.class); } }