[
https://issues.apache.org/jira/browse/UIMA-5807?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Peter Klügl updated UIMA-5807:
------------------------------
Description:
It is currently a bit cumbersome to use the uimaFIT factories together with
UIMA PEARs. A possible improvement in this direction could be to support the
pear wrappers in the AnalysisEngineFactory methods:
{code:java}
{code}
public static AnalysisEngineDescription createEngineDescription(
List<AnalysisEngineDescription> analysisEngineDescriptions, List<String>
componentNames,
TypePriorities typePriorities, SofaMapping[] sofaMappings,
FlowControllerDescription flowControllerDescription)
{code:java}
{code}
If another method is added or the given list uses ResourceSpecifier instead of
AnalysisEngineDescription (and some ifs in the loop), then PEARs would be
supported.
An exemplary implementation could look like:
{code:java}
{code}
public static AnalysisEngineDescription createEngineDescription(
List<ResourceSpecifier> resourceSpecifiers, List<String> componentNames,
TypePriorities typePriorities, SofaMapping[] sofaMappings,
FlowControllerDescription flowControllerDescription) {
if (componentNames == null)
{ throw new IllegalArgumentException("Parameter [componentNames] cannot be
null"); }
if (resourceSpecifiers == null)
{ throw new IllegalArgumentException("Parameter [analysisEngineDescriptions]
cannot be null"); }
if (resourceSpecifiers.size() != componentNames.size())
{ throw new IllegalArgumentException("Number of descriptions [" +
resourceSpecifiers.size() + "]does not match number of component names [" +
componentNames.size() + "]."); }
// create the descriptor and set configuration parameters
AnalysisEngineDescription desc = new AnalysisEngineDescription_impl();
desc.setFrameworkImplementation(Constants.JAVA_FRAMEWORK_NAME);
desc.setPrimitive(false);
// if any of the aggregated analysis engines does not allow multiple
// deployment, then the
// aggregate engine may also not be multiply deployed
boolean allowMultipleDeploy = true;
for (ResourceSpecifier d : resourceSpecifiers) {
// for now only consider AnalysisEngineDescriptions: we implicitly assume that
all pears have allowMultipleDeploy = true
if (d instanceof AnalysisEngineDescription)
{ allowMultipleDeploy &= ((AnalysisEngineDescription)
d).getAnalysisEngineMetaData().getOperationalProperties()
.isMultipleDeploymentAllowed(); }
}
desc.getAnalysisEngineMetaData().getOperationalProperties()
.setMultipleDeploymentAllowed(allowMultipleDeploy);
List<String> flowNames = new ArrayList<String>();
for (int i = 0; i < resourceSpecifiers.size(); i++)
{ ResourceSpecifier aed = resourceSpecifiers.get(i); String componentName =
componentNames.get(i);
desc.getDelegateAnalysisEngineSpecifiersWithImports().put(componentName, aed);
flowNames.add(componentName); }
if (flowControllerDescription != null)
{ FlowControllerDeclaration flowControllerDeclaration = new
FlowControllerDeclaration_impl();
flowControllerDeclaration.setSpecifier(flowControllerDescription);
desc.setFlowControllerDeclaration(flowControllerDeclaration); }
FixedFlow fixedFlow = new FixedFlow_impl();
fixedFlow.setFixedFlow(flowNames.toArray(new String[flowNames.size()]));
desc.getAnalysisEngineMetaData().setFlowConstraints(fixedFlow);
if (typePriorities != null)
{ desc.getAnalysisEngineMetaData().setTypePriorities(typePriorities); }
if (sofaMappings != null)
{ desc.setSofaMappings(sofaMappings); }
return desc;
}
{code:java}
{code}
was:
It is currently a bit cumbersome to use the uimaFIT factories together with
UIMA PEARs. A possible improvement int his direction could be to support the
pear wrappers in the AnalysisEngineFactory methods:
{code:java}
public static AnalysisEngineDescription createEngineDescription(
List<AnalysisEngineDescription> analysisEngineDescriptions, List<String>
componentNames,
TypePriorities typePriorities, SofaMapping[] sofaMappings,
FlowControllerDescription flowControllerDescription)
{code:java}
If another method is added or the given list uses ResourceSpecifier instead of
AnalysisEngineDescription (and some ifs in the loop), then PEARs would be
supported.
An exemplary implementation could look like:
{code:java}
public static AnalysisEngineDescription createEngineDescription(
List<ResourceSpecifier> resourceSpecifiers, List<String> componentNames,
TypePriorities typePriorities, SofaMapping[] sofaMappings,
FlowControllerDescription flowControllerDescription) {
if (componentNames == null) {
throw new IllegalArgumentException("Parameter [componentNames] cannot be
null");
}
if (resourceSpecifiers == null) {
throw new IllegalArgumentException("Parameter [analysisEngineDescriptions]
cannot be null");
}
if (resourceSpecifiers.size() != componentNames.size()) {
throw new IllegalArgumentException("Number of descriptions ["
+ resourceSpecifiers.size() + "]does not match number of component names ["
+ componentNames.size() + "].");
}
// create the descriptor and set configuration parameters
AnalysisEngineDescription desc = new AnalysisEngineDescription_impl();
desc.setFrameworkImplementation(Constants.JAVA_FRAMEWORK_NAME);
desc.setPrimitive(false);
// if any of the aggregated analysis engines does not allow multiple
// deployment, then the
// aggregate engine may also not be multiply deployed
boolean allowMultipleDeploy = true;
for (ResourceSpecifier d : resourceSpecifiers) {
// for now only consider AnalysisEngineDescriptions: we implicitly assume that
all pears have allowMultipleDeploy = true
if (d instanceof AnalysisEngineDescription) {
allowMultipleDeploy &= ((AnalysisEngineDescription)
d).getAnalysisEngineMetaData().getOperationalProperties()
.isMultipleDeploymentAllowed();
}
}
desc.getAnalysisEngineMetaData().getOperationalProperties()
.setMultipleDeploymentAllowed(allowMultipleDeploy);
List<String> flowNames = new ArrayList<String>();
for (int i = 0; i < resourceSpecifiers.size(); i++) {
ResourceSpecifier aed = resourceSpecifiers.get(i);
String componentName = componentNames.get(i);
desc.getDelegateAnalysisEngineSpecifiersWithImports().put(componentName, aed);
flowNames.add(componentName);
}
if (flowControllerDescription != null) {
FlowControllerDeclaration flowControllerDeclaration = new
FlowControllerDeclaration_impl();
flowControllerDeclaration.setSpecifier(flowControllerDescription);
desc.setFlowControllerDeclaration(flowControllerDeclaration);
}
FixedFlow fixedFlow = new FixedFlow_impl();
fixedFlow.setFixedFlow(flowNames.toArray(new String[flowNames.size()]));
desc.getAnalysisEngineMetaData().setFlowConstraints(fixedFlow);
if (typePriorities != null) {
desc.getAnalysisEngineMetaData().setTypePriorities(typePriorities);
}
if (sofaMappings != null) {
desc.setSofaMappings(sofaMappings);
}
return desc;
}
{code:java}
> Support PEARs (ResourceSpecifier) in
> AnalysisEngineFactory.createEngineDescription
> ----------------------------------------------------------------------------------
>
> Key: UIMA-5807
> URL: https://issues.apache.org/jira/browse/UIMA-5807
> Project: UIMA
> Issue Type: Improvement
> Components: uimaFIT
> Reporter: Peter Klügl
> Priority: Major
>
> It is currently a bit cumbersome to use the uimaFIT factories together with
> UIMA PEARs. A possible improvement in this direction could be to support the
> pear wrappers in the AnalysisEngineFactory methods:
>
> {code:java}
> {code}
> public static AnalysisEngineDescription createEngineDescription(
> List<AnalysisEngineDescription> analysisEngineDescriptions, List<String>
> componentNames,
> TypePriorities typePriorities, SofaMapping[] sofaMappings,
> FlowControllerDescription flowControllerDescription)
> {code:java}
> {code}
>
> If another method is added or the given list uses ResourceSpecifier instead
> of AnalysisEngineDescription (and some ifs in the loop), then PEARs would be
> supported.
>
> An exemplary implementation could look like:
>
> {code:java}
> {code}
> public static AnalysisEngineDescription createEngineDescription(
> List<ResourceSpecifier> resourceSpecifiers, List<String> componentNames,
> TypePriorities typePriorities, SofaMapping[] sofaMappings,
> FlowControllerDescription flowControllerDescription) {
> if (componentNames == null)
> { throw new IllegalArgumentException("Parameter [componentNames] cannot be
> null"); }
> if (resourceSpecifiers == null)
> { throw new IllegalArgumentException("Parameter [analysisEngineDescriptions]
> cannot be null"); }
> if (resourceSpecifiers.size() != componentNames.size())
> { throw new IllegalArgumentException("Number of descriptions [" +
> resourceSpecifiers.size() + "]does not match number of component names [" +
> componentNames.size() + "]."); }
> // create the descriptor and set configuration parameters
> AnalysisEngineDescription desc = new AnalysisEngineDescription_impl();
> desc.setFrameworkImplementation(Constants.JAVA_FRAMEWORK_NAME);
> desc.setPrimitive(false);
> // if any of the aggregated analysis engines does not allow multiple
> // deployment, then the
> // aggregate engine may also not be multiply deployed
> boolean allowMultipleDeploy = true;
> for (ResourceSpecifier d : resourceSpecifiers) {
> // for now only consider AnalysisEngineDescriptions: we implicitly assume
> that all pears have allowMultipleDeploy = true
> if (d instanceof AnalysisEngineDescription)
> { allowMultipleDeploy &= ((AnalysisEngineDescription)
> d).getAnalysisEngineMetaData().getOperationalProperties()
> .isMultipleDeploymentAllowed(); }
> }
> desc.getAnalysisEngineMetaData().getOperationalProperties()
> .setMultipleDeploymentAllowed(allowMultipleDeploy);
> List<String> flowNames = new ArrayList<String>();
> for (int i = 0; i < resourceSpecifiers.size(); i++)
> { ResourceSpecifier aed = resourceSpecifiers.get(i); String componentName =
> componentNames.get(i);
> desc.getDelegateAnalysisEngineSpecifiersWithImports().put(componentName,
> aed); flowNames.add(componentName); }
> if (flowControllerDescription != null)
> { FlowControllerDeclaration flowControllerDeclaration = new
> FlowControllerDeclaration_impl();
> flowControllerDeclaration.setSpecifier(flowControllerDescription);
> desc.setFlowControllerDeclaration(flowControllerDeclaration); }
> FixedFlow fixedFlow = new FixedFlow_impl();
> fixedFlow.setFixedFlow(flowNames.toArray(new String[flowNames.size()]));
> desc.getAnalysisEngineMetaData().setFlowConstraints(fixedFlow);
> if (typePriorities != null)
> { desc.getAnalysisEngineMetaData().setTypePriorities(typePriorities); }
> if (sofaMappings != null)
> { desc.setSofaMappings(sofaMappings); }
> return desc;
> }
> {code:java}
> {code}
>
>
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)