uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marshall Schor <...@schor.com>
Subject Re: UIMA ResultSpecification
Date Sun, 14 Apr 2013 18:30:35 GMT
Hi Georg,

I reproduced this behavior, and traced the root cause to a an edge case that,
although working as designed, is not quite documented correctly.

The key documentation is here:
http://uima.apache.org/d/uimaj-2.4.0/tutorials_and_users_guides.html#ugr.tug.aae.result_specification_setting

The part which isn't quite correct is the description for how "primitives" (as
contrasted to aggregates) handle result specification. 

The correct documentation should have said that primitives, as well as
aggregates, always pass in to the annotator, a result specification formed from
the intersection of the specified result specification, and the set of
types/features specified as being "output" from the annotator, in the
annotator's capabilities xml element.

Your example will start working if you add the following specification to your
analysis engine description, specifying that this primitive outputs the "test"
type with all features, by adding this bit of xml to your <analysisEngineMetaData> :

       <capabilities>
          <capability>
            <outputs>
              <type allAnnotatorFeatures="true">test</type>
            </outputs>
          </capability>
        </capabilities>

Without this, you are essentially telling UIMA that no outputs (new Types and/or
Features) are being added to the CAS by this annotator.  So the
ResultsSpecification is "empty".

-Marshall


On 4/14/2013 5:19 AM, Georg Fette wrote:
> 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
>>>
>
>


Mime
View raw message