On Tue, Mar 22, 2011 at 4:35 PM, Richard Matthias Eckart de Castilho
<[email protected]> wrote:
>
> Hi,
>
> in my opinion, the best would be if UIMA components were just Java 
> beans/POJOs.
>

Hi,
I did it. I've my version of analysisEngine:

public class IocPrimitiveAnalysisEngine extends AnalysisEngineImplBase
implements AnalysisEngine {

        public void setAnalysisComponent(AnalysisComponent analysisComponent) {
                mAnalysisComponent = analysisComponent;

        }

}

To build it i wrote some Spring FactoryBeans.
So you can configure Annotators this way:

        <bean name="regExpTokenizer-0"
class="uima.bean.CasProcessorFactoryBean" parent="baseAnnotator">
                <property name="component">
                        <bean class="uima.annotators.language.RegExpTokenizer"
parent="baseCasProcessor">
                                <property name="resourcesPattern"
value="commandsTokenizer_${key}.xml" /> <!--- a String--->
                                <property name="fileRepo" ref="fileSystem" /> 
<!--- a reference to
a bean--->
                        </bean>
                </property>
        </bean>

or in javaconfig:
        @Bean
        @Lazy
        public RegExpTokenizer regExpTokenizer() throws Exception {
                RegExpTokenizer tokenizer = new RegExpTokenizer();
                tokenizer.setResourcesPattern("commandsTokenizer_${key}.xml");
                tokenizer.setFileRepo(fileSystemRepository);
                tokenizer.setApplications(applications);
                
tokenizer.initialize(UimaContextFactory.createUimaContext(null));
                return tokenizer;
        }


        public AnalysisEngine createAnalysisEngine(AnalysisComponent
component) throws Exception {
                CasProcessorFactoryBean fc = new CasProcessorFactoryBean();
                fc.setBeanName(component.getClass().getSimpleName());
                fc.setComponent(component);
                
fc.setTypeSystem(TypeSystemDescriptionFactory.createTypeSystemDescription("completeTypeSystem"));
                fc.afterPropertiesSet();
                AnalysisEngine analysisEngine = (AnalysisEngine) fc.getObject();

                return analysisEngine;

        }


The factory bean (internals) :

                //create programmatically a descriptor
                AnalysisEngineDescription desc = createAnalysisDescriptor();

               //create engine
                AnalysisEngine engine = new IocPrimitiveAnalysisEngine();
                        ((IocPrimitiveAnalysisEngine) 
engine).setAnalysisComponent(component);
               //initialize
engine.initialize(desc, null);


I want to release this, but at the moment there are too many
dependency to internal code.

Pros:
- casProcessors, consumers and reader are POJO:
- can use spring
-  seamless your business logic: db access, internal api
- easy to test and inject mocks
cons:
- no different classloader (no PEAR)
- maybe lack of other  functionality, which I don't use :)

Now, with uimafit, it would be interesting to merge my feature with Fit.
Simply I don't have time  :(

FRANK
-- 
Roberto Franchini
http://www.celi.it
http://www.blogmeter.it
http://www.memesphere.it
Tel +39.011.562.71.15
jabber:[email protected] skype:ro.franchini

Reply via email to