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
(TypeSystemDescription typeSystemDescription, TypePriorities typePriorities, FlowControllerDescription flowControllerDescription) Instantiate an AggregateBuilder with a given type system, type priorities, and flow controller. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(String componentName, AnalysisEngineDescription aed, String... viewNames) add
(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.This method simply delegates toAnalysisEngineFactory.createEngine(List, TypeSystemDescription, TypePriorities, SofaMapping[], Object...)
with the data collected by this builder.This method simply delegates toAnalysisEngineFactory.createEngineDescription(List, TypeSystemDescription, TypePriorities, SofaMapping[], Object...)
with the data collected by this builder.void
setFlowControllerDescription
(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(TypeSystemDescription typeSystemDescription, TypePriorities typePriorities, 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
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
- 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
Set the flow controller description of the aggregate engine created by this builder.- Parameters:
flowControllerDescription
- seeFlowControllerFactory
-
createAggregate
This method simply delegates toAnalysisEngineFactory.createEngine(List, TypeSystemDescription, TypePriorities, SofaMapping[], Object...)
with the data collected by this builder.- Returns:
- an aggregate analysis engine
- Throws:
ResourceInitializationException
- if there is a problem during initialization
-
createAggregateDescription
public AnalysisEngineDescription createAggregateDescription() throws 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:
ResourceInitializationException
- if there is a problem during initialization
-