You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Franck Valentin <am...@yahoo.fr> on 2016/03/29 14:56:00 UTC
Dynamically set configuration parameters in delegates.
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
}
Re: Dynamically set configuration parameters in delegates.
Posted by Richard Eckart de Castilho <re...@apache.org>.
On 01.04.2016, at 18:12, Franck <fr...@yahoo.fr.INVALID> wrote:
>
> Hi Richard,
> thanks for your answer. I thought about it but didn't want to reconfigure the descriptors each time before running the pipeline. The parameters I want to set only concern my own AEs, so I guess the solution would then be to create a new annotation with all the parameters I need, change my AEs so that they read the values, and set this annotation before calling process().
> Cheers from Darmstadt :)Franck
UIMA supports defining overrides in aggregates [1] such that parameter of a component within an aggregate can be exposed as an aggregate parameter. uimaFIT has no explicit support for this, but the descriptors that uimaFIT creates are regular UIMA descriptors and you should be able to locate the proper methods to define overrides on an aggregate descriptor returned by uimaFIT.
What I do not know is whether these overrides remain in effect after the aggregate has been instantiated - i.e. whether you can call reconfigure() on the aggregate such that it would transitively reconfigure the delegate engines in the aggregate.
... but you could try it :) (or somebody more in the know may tell us)
Best,
-- Richard
[1] https://uima.apache.org/d/uimaj-current/references.html#ugr.ref.xml.component_descriptor.aes.aggregate.configuration_parameter_overrides
Re: Dynamically set configuration parameters in delegates.
Posted by Franck <fr...@yahoo.fr.INVALID>.
Hi Richard,
thanks for your answer. I thought about it but didn't want to reconfigure the descriptors each time before running the pipeline. The parameters I want to set only concern my own AEs, so I guess the solution would then be to create a new annotation with all the parameters I need, change my AEs so that they read the values, and set this annotation before calling process().
Cheers from Darmstadt :)Franck
De : Richard Eckart de Castilho <re...@apache.org>
À : user@uima.apache.org
Envoyé le : Mercredi 30 mars 2016 15h24
Objet : Re: Dynamically set configuration parameters in delegates.
Hi,
I would recommend reconfiguring a single AE instance, but rather generating new (aggregate) engine descriptions as you need them and uimaFIT SimplePipeline to run them.
I believe there is no standard way of reconfiguring components within already instantiated aggregates.
Best,
-- Richard
> On 29.03.2016, at 14:56, Franck Valentin <am...@yahoo.fr> wrote:
>
> 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).
Re: Dynamically set configuration parameters in delegates.
Posted by Richard Eckart de Castilho <re...@apache.org>.
Hi,
I would recommend reconfiguring a single AE instance, but rather generating new (aggregate) engine descriptions as you need them and uimaFIT SimplePipeline to run them.
I believe there is no standard way of reconfiguring components within already instantiated aggregates.
Best,
-- Richard
> On 29.03.2016, at 14:56, Franck Valentin <am...@yahoo.fr> wrote:
>
> 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).