uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Georg Fette <georg.fe...@uni-wuerzburg.de>
Subject Re: UIMA ResultSpecification
Date Sun, 14 Apr 2013 09:19:11 GMT
Oh sorry, I didn't notice I unintentionally used UIMAFit for my test. I 
rewrote the test so that it is now 'raw' UIMA. But still in this setup 
the TypeOrFeature[]-Array which is returned from the ResultSpecification 
is empty :-(

This is the code for my Test:

public class Test {

     public static AnalysisEngineDescription readAED() {
         AnalysisEngineDescription result = null;
         InputStream anInStream = 
Test.class.getResourceAsStream("/testEngine.xml");
         XMLParser xmlParser = UIMAFramework.getXMLParser();
         try {
             result = xmlParser.parseAnalysisEngineDescription(new 
XMLInputSource(anInStream, null));
         } catch (InvalidXMLException e) {
             e.printStackTrace();
         }
         return result;
     }

     public static void main(String[] args) {
         try {
             AnalysisEngineDescription aed = readAED();
             AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(aed);
             ResultSpecification resultSpec =
UIMAFramework.getResourceSpecifierFactory().createResultSpecification();
             resultSpec.addResultType("test", true);
             CAS cas = CasCreationUtils.createCas(aed);
             ae.process(cas, resultSpec);
         } catch (Exception e) {
             e.printStackTrace();
         }
     }

}

This is my engine class:

public class TestEngine extends CasAnnotator_ImplBase {
     @Override
     public void process(CAS arg0) throws AnalysisEngineProcessException {
         ResultSpecification resultSpec = getResultSpecification();
         TypeOrFeature[] types = resultSpec.getResultTypesAndFeatures();
     }
}

This is the typesystem:

<?xml version="1.0" encoding="UTF-8"?>
<typeSystemDescription xmlns="http://uima.apache.org/resourceSpecifier">
     <types>
         <typeDescription>
             <name>test</name>
             <description></description>
<supertypeName>uima.tcas.Annotation</supertypeName>
         </typeDescription>
     </types>
</typeSystemDescription>

And this is the AnalysisEngingeDescription:

<?xml version="1.0" encoding="UTF-8"?>
<analysisEngineDescription xmlns="http://uima.apache.org/resourceSpecifier">
     <primitive>true</primitive>
     <annotatorImplementationName>
         de.uniwue.test.uimaresultSpec.TestEngine
     </annotatorImplementationName>
     <analysisEngineMetaData>
         <typeSystemDescription>
<name>de.uniwue.dw.tm.TestTypeSystem</name>
             <imports>
                 <import location="src/typeSystem.xml"/>
             </imports>
         </typeSystemDescription>
     </analysisEngineMetaData>
</analysisEngineDescription>


Greetings
Georg

Am 14.04.2013 07:19, schrieb Marshall Schor:
>  From the source code you posted, it appears you are using UIMAFit, is this correct?
>
> How are you specifying the UIMA Type system (which would need to contain a
> definition for the type "test") for this?
>
> -Marshall
>
> On 4/13/2013 8:49 AM, Georg Fette wrote:
>> Hello,
>> I have a problem in understanding how to use the class "ResultSpecification".
>> I thought that before I call "process(cas)" I configure an instance of
>> ResultSpecification by adding types which have to be produced in the process
>> call. My test code looks like this:
>>
>> MainClass:
>> ------------------
>> AnalysisEngineDescription aed =
>> AnalysisEngineFactory.createPrimitiveDescription(TestEngine.class);
>> AnalysisEngine ae = AnalysisEngineFactory.createPrimitive(aed);
>> ResultSpecification resultSpec =
>> UIMAFramework.getResourceSpecifierFactory().createResultSpecification();
>> resultSpec.addResultType("test", true);
>> CAS cas = CasCreationUtils.createCas(aed);
>> ae.process(cas, resultSpec);
>>
>> TestEngine:
>> -------------------------
>>      @Override
>>      public void process(JCas arg0) throws AnalysisEngineProcessException {
>>          ResultSpecification resultSpec = getResultSpecification();
>>          TypeOrFeature[] types = resultSpec.getResultTypesAndFeatures();
>>      }
>>
>> Unfortunately the types-array in is retured by the resultSpec in the enginge's
>> process method is always empty.
>> What am I doing wrong ?
>> Greetings
>> Georg
>>


-- 
---------------------------------------------------------------------
Dipl.-Inf. Georg Fette      Raum: B009
Universität Würzburg        Tel.: +49-(0)931-31-85516
Am Hubland                  Fax.: +49-(0)931-31-86732
97074 Würzburg              mail: georg.fette@uni-wuerzburg.de
---------------------------------------------------------------------


Mime
View raw message