JCas type used in Java code, but was not declared in the XML type descriptor

588 views Asked by At

I am new in DKPro Core even in UIMA and uimaFIT. I am trying to run a project but getting the error: JCas type "de.tudarmstadt.ukp.dkpro.core.discourse.pdtb.DiscourseArgument" used in Java code, but was not declared in the XML type descriptor

In the code, the descriptor:

AnalysisEngineDescription preprocessing = createEngineDescription(
                        createEngineDescription(LanguageToolSegmenter.class),
                        createEngineDescription(ParagraphAnnotator.class),
                        createEngineDescription(MateLemmatizer.class, MateLemmatizer.PARAM_LANGUAGE, "en"),
                        createEngineDescription(SnowballStemmer.class),
                        createEngineDescription(StanfordParser.class, StanfordParser.PARAM_WRITE_PENN_TREE, true),
                        createEngineDescription(StanfordSentimentAnnotator.class),
                                createEngineDescription(PDTBDiscourseAnnotator.class)
                );

de.tudarmstadt.ukp.dkpro.core.discourse.pdtb.DiscourseArgument is used in PDTBDiscourseAnnotator.class in th efollowing line:

 DiscourseArgument discourseArgument = new DiscourseArgument(jCas);

and the error is starting from there.

As far as I understand from the uimaFIT documentation, that using uimaFIT we don't need XML descriptor if we use createEngineDescription(class_name), if so, then why the error says: "not declared in the XML type descriptor".

Other classes for example: "SnowballStemmer.class" use the same kind of calling like intantiate another class with jcas argument

Stem stemAnnot = new Stem(jcas, fs.getBegin(), fs.getEnd());

but error is not happening in those cases.

Any idea or clue about this error? Is my understanding correct

1

There are 1 answers

8
rec On

This error appears when you have generated a JCas class give a given type and use it in your code but at the same time, the (J)CAS has not been initialized with a type system containing that type.

What does it mean in practice?

  • You have some UIMA type system description XML file somewhere which defines your type DiscourseArgument.
  • You have used JCasGen to create a JCas Java class from that type system.
  • You are using uimaFIT to construct your pipeline (i.e. createEngineDescription(...)).
  • uimaFIT automatically scans the class path for UIMA type system description XML files to use when initializing the pipeline.
  • However, you have not made uimaFIT aware of your own type description file and therefore uimaFIT does not find it and you get the error.

How to resolve it?

You need to follow some conventions such that uimaFIT is able to detect and load your custom type:

  • create a file META-INF/org.apache.uima.fit/types.txt in a source folder (if you are using Maven, then under src/main/resources.
  • put into it the location of your type description xml file, e.g. classpath*:some/package/my-custom-type-description.xml

Once you did that, uimaFIT should automatically detect your type and the error should go away.

Why does it not happen with DKPro Core's own classes?

Because the DKPro Core artifacts include META-INF/org.apache.uima.fit/types.txt files which allow uimaFIT to auto-detect the types.