Package org.apache.uima.fit.factory
Class AggregateBuilder
java.lang.Object
org.apache.uima.fit.factory.AggregateBuilder
This builder makes it easier to create an aggregate analysis engine. A typical use-case would
involve initializing this builder with your preferred type system and type priorities (the latter
may be null). This is followed by adding analysis engine descriptions one at a time until done.
This makes it easy to have runtime decisions determine how the aggregate engine should be built.
Finally, one of the create methods are called and an AnalysisEngine or AnalysisEngineDescription
is returned.
This is an example taken from our test cases:
import static org.apache.uima.fit.factory.AnalysisEngineFactory.createPrimitiveDescription;
AggregateBuilder builder = new AggregateBuilder();
builder.add(createPrimitiveDescription(Annotator1.class, typeSystemDescription),
ViewNames.PARENTHESES_VIEW, "A");
builder.add(createPrimitiveDescription(Annotator2.class, typeSystemDescription),
ViewNames.SORTED_VIEW, "B",
ViewNames.SORTED_PARENTHESES_VIEW, "C",
ViewNames.PARENTHESES_VIEW, "A");
builder.add(createPrimitiveDescription(Annotator3.class, typeSystemDescription),
ViewNames.INITIAL_VIEW, "B");
AnalysisEngine aggregateEngine = builder.createAggregate();
-
Constructor Summary
ConstructorDescriptionThe default no-args constructor callsAggregateBuilder(TypeSystemDescription, TypePriorities, FlowControllerDescription)
with null-valued args.AggregateBuilder
(org.apache.uima.resource.metadata.TypeSystemDescription typeSystemDescription, org.apache.uima.resource.metadata.TypePriorities typePriorities, org.apache.uima.flow.FlowControllerDescription flowControllerDescription) Instantiate an AggregateBuilder with a given type system, type priorities, and flow controller. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(String componentName, org.apache.uima.analysis_engine.AnalysisEngineDescription aed, String... viewNames) This method simply callsadd(String, AnalysisEngineDescription, String...)
using the result ofAnalysisEngineDescription.getAnnotatorImplementationName()
for the component namevoid
addSofaMapping
(String componentName, String componentViewName, String aggregateViewName) Provide a sofa mapping for a component from the component's view to the aggregate view.org.apache.uima.analysis_engine.AnalysisEngine
This method simply delegates toAnalysisEngineFactory.createEngine(List, TypeSystemDescription, TypePriorities, SofaMapping[], Object...)
with the data collected by this builder.org.apache.uima.analysis_engine.AnalysisEngineDescription
This method simply delegates toAnalysisEngineFactory.createEngineDescription(List, TypeSystemDescription, TypePriorities, SofaMapping[], Object...)
with the data collected by this builder.void
setFlowControllerDescription
(org.apache.uima.flow.FlowControllerDescription flowControllerDescription) Set the flow controller description of the aggregate engine created by this builder.
-
Constructor Details
-
AggregateBuilder
public AggregateBuilder()The default no-args constructor callsAggregateBuilder(TypeSystemDescription, TypePriorities, FlowControllerDescription)
with null-valued args. -
AggregateBuilder
public AggregateBuilder(org.apache.uima.resource.metadata.TypeSystemDescription typeSystemDescription, org.apache.uima.resource.metadata.TypePriorities typePriorities, org.apache.uima.flow.FlowControllerDescription flowControllerDescription) Instantiate an AggregateBuilder with a given type system, type priorities, and flow controller. Generally, speaking it suffices to use the no arguments constructor- Parameters:
typeSystemDescription
- this can be instantiated usingTypeSystemDescriptionFactory
typePriorities
- this can be instantiated usingTypePrioritiesFactory
flowControllerDescription
- this can be instantiated usingFlowControllerFactory
-
-
Method Details
-
add
public String add(org.apache.uima.analysis_engine.AnalysisEngineDescription aed, String... viewNames) This method simply callsadd(String, AnalysisEngineDescription, String...)
using the result ofAnalysisEngineDescription.getAnnotatorImplementationName()
for the component name- Parameters:
aed
- an analysis engine description to add to the aggregate analysis engineviewNames
- pairs of view names corresponding to a componentSofaName followed by the aggregateSofaName that it is mapped to. An even number of names must be passed in or else an IllegalArgumentException will be thrown. SeeSofaMappingFactory.createSofaMapping(String, String, String)
- Returns:
- the name of the component generated for the
AnalysisEngineDescription
-
add
public void add(String componentName, org.apache.uima.analysis_engine.AnalysisEngineDescription aed, String... viewNames) - Parameters:
componentName
- the name of the component to addaed
- an analysis engine description to add to the aggregate analysis engineviewNames
- pairs of view names corresponding to a componentSofaName followed by the aggregateSofaName that it is mapped to. An even number of names must be passed in or else an IllegalArgumentException will be thrown. SeeSofaMappingFactory.createSofaMapping(String, String, String)
-
addSofaMapping
public void addSofaMapping(String componentName, String componentViewName, String aggregateViewName) Provide a sofa mapping for a component from the component's view to the aggregate view.- Parameters:
componentName
- the name of the componentcomponentViewName
- the name of the component viewaggregateViewName
- the name of the aggregate view to map the component view to.
-
setFlowControllerDescription
public void setFlowControllerDescription(org.apache.uima.flow.FlowControllerDescription flowControllerDescription) Set the flow controller description of the aggregate engine created by this builder.- Parameters:
flowControllerDescription
- seeFlowControllerFactory
-
createAggregate
public org.apache.uima.analysis_engine.AnalysisEngine createAggregate() throws org.apache.uima.resource.ResourceInitializationExceptionThis method simply delegates toAnalysisEngineFactory.createEngine(List, TypeSystemDescription, TypePriorities, SofaMapping[], Object...)
with the data collected by this builder.- Returns:
- an aggregate analysis engine
- Throws:
org.apache.uima.resource.ResourceInitializationException
- if there is a problem during initialization
-
createAggregateDescription
public org.apache.uima.analysis_engine.AnalysisEngineDescription createAggregateDescription() throws org.apache.uima.resource.ResourceInitializationExceptionThis method simply delegates toAnalysisEngineFactory.createEngineDescription(List, TypeSystemDescription, TypePriorities, SofaMapping[], Object...)
with the data collected by this builder.- Returns:
- a description of an aggregate analysis engine
- Throws:
org.apache.uima.resource.ResourceInitializationException
- if there is a problem during initialization
-