uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Eckart de Castilho <...@apache.org>
Subject Re: Change an <externalResource> <fileResourceSpecifier> <fileUrl> at run-time
Date Sat, 19 Mar 2016 21:25:44 GMT

you might find this interesting (although I haven't used that in a long time):


Also, after you a have parser the specifier in the last line of your code,
you can traverse it, locate the element you wish to change and simply change
it at runtime. In that case it doesn't matter what the XML file contains.

The Java object structure is very similar to the XML structure. It may be a 
bit verbose to actually get to the point where you want to go and *maybe*
you'll have to cast some interfaces to their implementations to get access
to setters, but in general it should work.


-- Richard

> On 16.03.2016, at 23:46, D. Heinze <dheinze@gnoetics.com> wrote:
> I have separate xml engine descriptor files for set of ConceptMapper
> engines, each using a distinct compiled dictionary file that is specified in
> <fileUrl> as shown below.
> The ConceptMapper engines are configured and run programmatically by one of
> the engines in the overall UIMA pipeline, where the engines are run
> selectively on data that is constructed on the fly.
> Because all the descriptor files are alike (with stop word definitions,
> etc.) except for the <fileUrl> that specifies the dictionary, I would like
> to be able to have only one xml descriptor and be able to set a version
> number as a Java -D parameter when starting the engine and then add it to
> the <fileUrl> name after the ResourceSpecifier is created and before
> produceAnalysisEngine is called.
> Is this possible?  Or, can <fileUrl> somehow be omitted from the descriptor
> file and specified at run-time as a configuration parameter?
> Thanks / Dan 
>      is = cls.getClassLoader().getResourceAsStream( desc); 
>      XMLInputSource source = new XMLInputSource( is,  null); 
>      ResourceSpecifier specifier =
> UIMAFramework.getXMLParser().parseResourceSpecifier( source);        
>      ae = UIMAFramework.produceAnalysisEngine(specifier);
> DESCRIPTOR (desc):
> <?xml version="1.0" encoding="UTF-8"?>
> <analysisEngineDescription xmlns="http://uima.apache.org/resourceSpecifier">
>  <frameworkImplementation>org.apache.uima.java</frameworkImplementation>
>  <primitive>true</primitive>
> <annotatorImplementationName>org.apache.uima.conceptMapper.ConceptMapper</an
> notatorImplementationName>
> ...
>  <resourceManagerConfiguration>
>    <externalResources>
>      <externalResource>
>        <name>DictionaryFileName</name>
>        <description>A file containing the dictionary. Modify this URL to
> use a different dictionary.</description>
>        <fileResourceSpecifier>
> <fileUrl>com/gnoetics/resources/dictionary/ConceptMapperRoots_dict</fileUrl>
>         </fileResourceSpecifier>
> <implementationName>org.apache.uima.conceptMapper.support.dictionaryResource
> .CompiledDictionaryResource_impl</implementationName>
>      </externalResource>
>    </externalResources>
>    <externalResourceBindings>
>      <externalResourceBinding>
>        <key>DictionaryFile</key>
>        <resourceName>DictionaryFileName</resourceName>
>      </externalResourceBinding>
>    </externalResourceBindings>
>  </resourceManagerConfiguration>
> </analysisEngineDescription>

View raw message