Richard, Burn... thanks for the replies. I'll try the -D option which appears to be just what I wanted. Prior to the replies, I had done what Richard also suggested and intercepted the file input stream, modified the XML descriptor and then sent it on parseResourceSpecifier. I had also tried using uimafit, but it looked like ConceptMapper doesn't implement what uimafit needs. Thanks / Dan
-----Original Message----- From: Burn Lewis [mailto:[email protected]] Sent: Monday, March 21, 2016 1:23 PM To: [email protected] Subject: Re: Change an <externalResource> <fileResourceSpecifier> <fileUrl> at run-time The link Richard provided indicates that the substitution may be used for a <fileResourceSpecifier> so use: <fileUrl><envVarRef>DictionaryUrl</envVarRef></fileUrl> with -DDictionaryUrl=com/gnoetics/resources/dictionary/ConceptMapperRoots_dict (I verified that it works with a file: URL) For arbitrary modification of descriptors you can use -Duima.framework_impl to provide an implementation of UIMAFramework_impl that supports an XMLParser that modifies the XML before passing it to the UIMA parser. ~Burn On Sat, Mar 19, 2016 at 5:25 PM, Richard Eckart de Castilho <[email protected]> wrote: > Hi, > > you might find this interesting (although I haven't used that in a > long > time): > > > https://uima.apache.org/d/uimaj-current/references.html#ugr.ref.xml.co > mponent_descriptor.aes.environment_variable_references > > 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. > > Cheers, > > -- Richard > > > On 16.03.2016, at 23:46, D. Heinze <[email protected]> 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 > > > > ENGINE INITIALIZATION CODE: > > 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</frameworkImplementati > > on> > > <primitive>true</primitive> > > > > > <annotatorImplementationName>org.apache.uima.conceptMapper.ConceptMapp > er</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</fi > leUrl> > > </fileResourceSpecifier> > > > > > <implementationName>org.apache.uima.conceptMapper.support.dictionaryRe > source > > .CompiledDictionaryResource_impl</implementationName> > > </externalResource> > > </externalResources> > > <externalResourceBindings> > > <externalResourceBinding> > > <key>DictionaryFile</key> > > <resourceName>DictionaryFileName</resourceName> > > </externalResourceBinding> > > </externalResourceBindings> > > </resourceManagerConfiguration> > > </analysisEngineDescription> > > > >
