You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Luigi Cosentino <lu...@exeura.com> on 2008/07/09 09:58:21 UTC
CPE external parameters configuration
Hi all,
I'm a new UIMA user. I'm developing a CPM able to process pdf documents. I
need to set some parameters for each analysis engine using the related
descriptor, and some other programmatically.
I'm not able to do this. In particular, I correctly set the parameters into
the AE descriptor, but when I write my code to set the parameters
programmatically I always obtain a NullPointerException.
In the following I post an example of the code I use:
public void initialize(UimaContext context) throws
ResourceInitializationException
{
// Get the parameter representing a regular expression
String regexp = (String) context.getConfigParameterValue("REG_EXP");
...
}
In the CPM class I write the following code
...
ResourceSpecifier aeSpecifier =
UIMAFramework.getXMLParser().parseResourceSpecifier(
new XMLInputSource("myAnalysisEngineDescriptor.xml"));
AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(aeSpecifier);
ae.getMetaData().getConfigurationParameterSettings().setParameterValue("REG_EXP",
"myRegExp");
If the REG_EXP parameter has been declared in the AE descriptor, then I'm
able to set its value, else I obtain the NullPointerException when the
annotator use the regexp variable.
Note that I used ae.reconfigure() method, too, without any result.
Is it possible to solve this problem?
Regards.
Gg.
Re: CPE external parameters configuration
Posted by Christoph Büscher <ch...@neofonie.de>.
Hi Luigi,
I think the call to UIMA.produceAnalysisEngine() will already implicitly call
your annotators initialize() method and if you haven't set the value to a
default in your XML decriptor, this will result in the NPE.
You could try to set a reasonable default value in the XML and then reconfigure
it before using the AE. Or you could try to manipulate the ResourceSpecifier
before creating the AE via the UIMAFramework. I remember that I tried this once
but it was a bit awkward...
Hope this helps,
Christoph
Luigi Cosentino schrieb:
> Hi all,
>
> I'm a new UIMA user. I'm developing a CPM able to process pdf documents. I
> need to set some parameters for each analysis engine using the related
> descriptor, and some other programmatically.
> I'm not able to do this. In particular, I correctly set the parameters into
> the AE descriptor, but when I write my code to set the parameters
> programmatically I always obtain a NullPointerException.
> In the following I post an example of the code I use:
>
> public void initialize(UimaContext context) throws
> ResourceInitializationException
> {
> // Get the parameter representing a regular expression
> String regexp = (String) context.getConfigParameterValue("REG_EXP");
> ...
> }
>
> In the CPM class I write the following code
>
> ...
> ResourceSpecifier aeSpecifier =
> UIMAFramework.getXMLParser().parseResourceSpecifier(
> new XMLInputSource("myAnalysisEngineDescriptor.xml"));
> AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(aeSpecifier);
>
> ae.getMetaData().getConfigurationParameterSettings().setParameterValue("REG_EXP",
> "myRegExp");
>
> If the REG_EXP parameter has been declared in the AE descriptor, then I'm
> able to set its value, else I obtain the NullPointerException when the
> annotator use the regexp variable.
> Note that I used ae.reconfigure() method, too, without any result.
>
> Is it possible to solve this problem?
>
> Regards.
> Gg.
>