【发布时间】:2017-01-08 23:06:46
【问题描述】:
我正在尝试添加附加功能“版本”以在 UIMA CAS 中存储“uima.cas.Long”类型值。
我已经成功创建了如下所示的 XML 描述符:
<?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>
我使用“UIMA JCasGen”生成了相应的代码。
生成了以下类:
CASVersion_Type.java
CASVersion.java
现在,我想为 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)
CASVersion.java第51行代码如下:
50: public CASVersion(JCas jcas) {
51: super(jcas);
52: readObject();
53: }
因为我是第一次这样做,所以我无法弄清楚如何将我的自定义 xml 描述符合并到现有的 XML 类型描述符。
如果有人能指导我,那就太好了。
提前致谢。
【问题讨论】:
标签: exception annotations nlp cas uima