例外情况;CASRuntimeException“;创建自定义Apache UIMA CAS XML描述符时
我正在尝试添加附加功能“version”,用于在uima cas中存储“uima.cas.Long”类型值 我已经成功地创建了如下所示的XML描述符:例外情况;CASRuntimeException“;创建自定义Apache UIMA CAS XML描述符时,exception,annotations,nlp,cas,uima,Exception,Annotations,Nlp,Cas,Uima,我正在尝试添加附加功能“version”,用于在uima cas中存储“uima.cas.Long”类型值 我已经成功地创建了如下所示的XML描述符: <?xml version="1.0" encoding="UTF-8"?> <typeSystemDescription xmlns="http://uima.apache.org/resourceSpecifier"> <types> <typeDescription>
<?xml version="1.0" encoding="UTF-8"?>
<typeSystemDescription xmlns="http://uima.apache.org/resourceSpecifier">
<types>
<typeDescription>
<name>CASVersion</name>
<description/>
<supertypeName>uima.cas.TOP</supertypeName>
<features>
<featureDescription>
<name>Version</name>
<description/>
<rangeTypeName>uima.cas.Long</rangeTypeName>
</featureDescription>
</features>
</typeDescription>
</types>
</typeSystemDescription>
50: public CASVersion(JCas jcas) {
51: super(jcas);
52: readObject();
53: }
JCas document = CasCreationUtils.createCas((TypeSystemDescription) null, null, null).getJCas();
现在,我想为JCas添加一个版本,我在java类中编写了以下代码:
14: public void testAnnotation() {
15: JCas document = CasCreationUtils.createCas((TypeSystemDescription) null, null, null).getJCas();
16: CASVersion version = new CASVersion(document);
17: version.setVersion(1);
我在运行下面提到的代码时得到“CASRuntimeException”:
null
org.apache.uima.cas.CASRuntimeException: JCas type "com.example.test.CASVersion" used in Java code, but was not declared in the XML type descriptor.
at org.apache.uima.jcas.impl.JCasImpl.getTypeInit(JCasImpl.java:456)
at org.apache.uima.jcas.impl.JCasImpl.getType(JCasImpl.java:425)
at org.apache.uima.jcas.cas.TOP.<init>(TOP.java:96)
at com.example.test.CASVersion.<init>(CASVersion.java:51)
at com.example.test.Custom.testAnnotation(Custom.java:15)
因为这是我第一次这样做,所以我不知道如何将自定义xml描述符合并到现有的xml类型描述符
如果有人能在这方面指导我,那就太好了
提前感谢。此消息
JCas type "com.example.test.CASVersion" used in Java code,
but was not declared in the XML type descriptor.
表示自定义类型的JCas类存在,但UIMA不知道描述自定义类型的XML描述符。假设您正在使用uimaFIT,请确保通过创建指向自定义类型的XML描述符的types.txt文件设置了类型系统检测。有关详细信息,请参阅
披露:我正在处理uimaFIT此消息
JCas type "com.example.test.CASVersion" used in Java code,
but was not declared in the XML type descriptor.
表示自定义类型的JCas类存在,但UIMA不知道描述自定义类型的XML描述符。假设您正在使用uimaFIT,请确保通过创建指向自定义类型的XML描述符的types.txt文件设置了类型系统检测。有关详细信息,请参阅
披露:我正在处理uimaFIT当我初始化JCas时,JCas中没有识别新类型,如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<typeSystemDescription xmlns="http://uima.apache.org/resourceSpecifier">
<types>
<typeDescription>
<name>CASVersion</name>
<description/>
<supertypeName>uima.cas.TOP</supertypeName>
<features>
<featureDescription>
<name>Version</name>
<description/>
<rangeTypeName>uima.cas.Long</rangeTypeName>
</featureDescription>
</features>
</typeDescription>
</types>
</typeSystemDescription>
50: public CASVersion(JCas jcas) {
51: super(jcas);
52: readObject();
53: }
JCas document = CasCreationUtils.createCas((TypeSystemDescription) null, null, null).getJCas();
通过将其替换为以下任意一项来解决此问题:
//1st way
JCas document = JCasFactory.createJCas();
//2nd way
TypeSystemDescription tsd = TypeSystemDescriptionFactory.createTypeSystemDescription();
JCas document = CasCreationUtils.createCas(tsd, null, null).getJCas();
当我按如下方式初始化JCas时,新类型在JCas中未被识别:
<?xml version="1.0" encoding="UTF-8"?>
<typeSystemDescription xmlns="http://uima.apache.org/resourceSpecifier">
<types>
<typeDescription>
<name>CASVersion</name>
<description/>
<supertypeName>uima.cas.TOP</supertypeName>
<features>
<featureDescription>
<name>Version</name>
<description/>
<rangeTypeName>uima.cas.Long</rangeTypeName>
</featureDescription>
</features>
</typeDescription>
</types>
</typeSystemDescription>
50: public CASVersion(JCas jcas) {
51: super(jcas);
52: readObject();
53: }
JCas document = CasCreationUtils.createCas((TypeSystemDescription) null, null, null).getJCas();
通过将其替换为以下任意一项来解决此问题:
//1st way
JCas document = JCasFactory.createJCas();
//2nd way
TypeSystemDescription tsd = TypeSystemDescriptionFactory.createTypeSystemDescription();
JCas document = CasCreationUtils.createCas(tsd, null, null).getJCas();
我正在使用uimaFIT,并且已经尝试了类型系统检测中提到的两种方法,但是我仍然得到相同的异常。是否有可能在POM.xml中缺少uimaFIT的任何依赖项并导致此问题?假设您将types.txt作为xml类型描述符和JCas类维护在同一个项目中,那么当Java能够找到JCas类时,uimaFIT应该能够发现该类型-在这种情况下,Java将为您提供“ClassNotFoundException”。您可以通过增加
TypeSystemDescription
类的日志级别或在org.apache.uima.fit.factory.TypeSystemDescriptionFactory.createTypeSystemDescription()中设置断点来调试uimaFIT类型检测
我正在使用uimaFIT,并且已经尝试了类型系统检测中提到的两种方法,但是我仍然得到相同的异常。是否有可能POM.xml中缺少uimaFIT的任何依赖项并导致此问题?假设您将types.txt作为xml类型描述符和JC维护在同一项目中作为类,当Java能够找到JCas类时,uimaFIT应该能够发现类型——在这种情况下,Java会给您一个“ClassNotFoundException”“。您可以通过增加TypeSystemDescription
类的日志级别或在org.apache.uima.fit.factory.TypeSystemDescriptionFactory.createTypeSystemDescription()中设置断点来调试uimaFIT类型检测。