uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niels Ott <n...@sfs.uni-tuebingen.de>
Subject Re: Setting Aggregate AE Parameters
Date Wed, 26 Nov 2008 18:51:14 GMT

Hi Christoph,

yes, the specifier actually should have been named description. I 
followed your instructions and they worked for me. Thank you very much!

I'm using a Properties object and of course I can only obtain String 
objects from it. settings.setParameterValue(name, value) requires the 
type of value to match the type specified in the descriptor. Here's a 
little trick that does it:

private Object autoConvertParameter(Object originalParameter, String 
value) {
	if ( originalParameter instanceof Boolean) {
		return Boolean.parseBoolean(value);
	}
	if ( originalParameter instanceof Integer) {
		return Integer.parseInt(value);
	}
	if ( originalParameter instanceof Float) {
		return Float.parseFloat(value);
	}
	// fallback: return as string
	return new String(value);
}

Object genericTypeValue = 
autoConvertParameter(settings.getParameterValue(key), value);

settings.setParameterValue(key, genericTypeValue);

If there is a more elegant solution, let me know. The hack above will of 
course fail in certain situations (wrong config values), but at least it 
won't run into producing garbage.

Best,

    Niels


Christoph B├╝scher schrieb:
> Hi Niels,
> 
> you might want to try to modify what you call the 'specifier' (I guess 
> its a AnalysisEngineDescription) before you call
> 
> UIMAFramework.produceAnalysisEngine(specifier)
> 
> I used this in Unit tests during setup, something like this:
> 
> --------
> URL descResource = 
> LexProcessingWriterTest.class.getClassLoader().getResource(          
> "MyDescriptor.xml");
> 
> AnalysisEngineDescription) aeDescription = 
> UIMAFramework.getXMLParser().parseAnalysisEngineDescription(
>                 new XMLInputSource(descResource));
> 
> ConfigurationParameterSettings settings = 
> aeDescription.getAnalysisEngineMetaData().getConfigurationParameterSettings(); 
> 
> ------------
> 
> Now that you have the settings you can set/overwrite values like:
> 
> settings.setParameterValue(name, value);
> 
> At the end when you produce the analysis engine with the modified values 
> there shouldn't be any problem:
> 
> myAE = UIMAFramework.produceAnalysisEngine(aeDescription);
> 
> Hope that helps,
> 
> Christoph
> 
> 
> Niels Ott schrieb:
>> Hello everybody,
>>
>> I'm new to this mailing list, however I'm not so new to UIMA.
>>
>> Here's my issue: I am trying to set the parameters of an Aggregate AE 
>> from within my Java program.
>>
>> I tried the following the solution I found here: 
>> http://www.mail-archive.com/uima-user@incubator.apache.org/msg01241.html#
>>
>> which is basically to produce an annotator and then to configure it using
>>
>>   annotator.setConfigParameterValue("ParamName","NewValue");
>>
>> This does not work for me as
>>
>>   annotator  = UIMAFramework.produceAnalysisEngine(specifier);
>>
>> which I'm using before to produce the Aggregate initializes its AEs 
>> with the default parameters. These default parameters are of course 
>> not suitable for use in the given scenario, causing the initialization 
>> to fail before I correct the configuration.
>>
>> I tried to use
>>
>>    produceAnalysisEngine(ResourceSpecifier aSpecifier, Map
>>       aAdditionalParams)
>>
>> instead but the additional parameters don't do the job. Perhaps I 
>> misunderstood the purpose of these additional parameters in the function.
>>
>> How can I specify the parameteres of an (Aggregate) AE before it is 
>> initialized?
>>
>> Thank you very much for your assistance.
>>
>> Best,
>>
>>    Niels Ott
>>
>>
>>
> 
> 


-- 
Niels Ott
Computational Linguist (B.A.)
http://www.drni.de/niels/

Mime
View raw message