Hi,
I use UIMA 2.6 and uimaFIT 2.1.0 to create an aggregate AE.
I would like to set specific parameters for each delegate before running
analyses (i.e. before running process()).
So far I tried to use configuration parameters but without success. If I
use a simple AE alone then calling
setConfigParameterValue() works but it doesn't when using an aggregate AE.
I stumbled also on a strange behavior: if the configuration parameter is
not defined in the engine description but its value is
set by setConfigParameterValue() then its name doesn't appear with
getConfigParameterNames() but its value is correctly retrieved
with getConfigParameterValue()!
Below is a simple code to test the aggregate (it's in Scala but should be
easily understandable).
object TestConfigForAggregate extends App {
val myConfigParamName = "myConfigParam"
class MyAnnotator extends JCasAnnotator_ImplBase {
override def process(jcas: JCas) {
println("config parameter names=" +
getContext().getConfigParameterNames.toList)
println(myConfigParamName + "=" +
getContext()
.getConfigParameterValue(myConfigParamName)
.asInstanceOf[String])
println()
}
}
def runAnalysisEngine(ae: AnalysisEngine) {
ae.setConfigParameterValue(myConfigParamName, "myValue")
ae.reconfigure()
val jcas = ae.newJCas()
jcas.setDocumentText("some text.")
ae.process(jcas)
//ae.destroy()
}
//
==========================================================================
// Main
//
==========================================================================
// 1. If the configuration parameter is not defined in the engine
description
// but its value is set by setConfigParameterValue() then its name
doesn't
// appear in getConfigParameterNames() but its value is correctly
retrieved!
val myAnnotatorAED1 =
AnalysisEngineFactory.createEngineDescription(classOf[MyAnnotator])
val ae1 = UIMAFramework.produceAnalysisEngine(myAnnotatorAED1)
runAnalysisEngine(ae1)
// displays:
// config parameter names=List()
// myConfigParam=myValue
// 2. If the configuration parameter is defined in the engine description
// and its value changed afterwards then everything works as expected.
val myAnnotatorAED2 = AnalysisEngineFactory.createEngineDescription(
classOf[MyAnnotator],
myConfigParamName, "defaultValue myAnnotatorAED2"
)
val ae2 = UIMAFramework.produceAnalysisEngine(myAnnotatorAED2)
runAnalysisEngine(ae2)
// displays:
// config parameter names=List(myConfigParam)
// myConfigParam=myValue
// 3. How can the configuration parameter's value be changed if the
// annotator is in an aggregate? Ideally the value can be changed from
the
// AE, not the description.
val aggregateAED =
AnalysisEngineFactory.createEngineDescription(myAnnotatorAED2)
val aggregateAE = UIMAFramework.produceAnalysisEngine(aggregateAED)
runAnalysisEngine(aggregateAE)
// displays:
// config parameter names=List(myConfigParam)
// myConfigParam=defaultValue myAnnotatorAED2
}