我使用gradle配置了heidelTime。但是,我得到的值不能迭代字符串的结果。
result = heidelTime.process(sentence, new Date());
JCas cas = JCasFactory.createJCas();
FSIterator it = cas.getAnnotationIndex(Timex3.type).iterator(); // Here I am getting error错误是由于JCasImpl.class->TOP_Type getType(int )造成的。
if (this.casImpl.getTypeSystem().getType(typeName) == null) {
// no - report error that JCAS type was not defined in XML
// descriptor
CASRuntimeException casEx = new CASRuntimeException(
CASRuntimeException.JCAS_TYPE_NOT_IN_CAS, new String[] { typeName });
throw casEx;
}我查看了github项目,看到了定义类型系统的HeidelTime_TypeSystem.xml文件。
级配置
compile group: 'com.github.heideltime', name: 'heideltime', version: '2.2.1'
compile group: 'org.apache.uima', name: 'uimaj-core', version: '2.3.1'堆栈跟踪
org.apache.uima.cas.CASRuntimeException: JCas type de.unihd.dbs.uima.types.heideltime.Timex3" used in Java code, but was not declared in the XML type descriptor.
at org.apache.uima.jcas.impl.JCasImpl.getType(JCasImpl.java:412) ~[uimaj-core-2.3.1.jar:2.3.1]
at org.apache.uima.jcas.impl.JCasImpl.getCasType(JCasImpl.java:436) ~[uimaj-core-2.3.1.jar:2.3.1]
at org.apache.uima.jcas.impl.JCasImpl.getAnnotationIndex(JCasImpl.java:1531) ~[uimaj-core-2.3.1.jar:2.3.1]我需要手动添加任何文件才能正常工作吗?
types.txt文件位置

发布于 2019-05-17 07:38:21
当使用UIMA类型的JCas类而不为该类型配置CAS时,就会发生这种情况。
打给
JCas cas = JCasFactory.createJCas();扫描类路径中名为types.txt的META-INF/org.apache.uima.fit/文件(因此一个名为META-INF的文件夹带有一个名为org.apache.uima.fit的子文件夹,然后包含types.txt文件),并加载其中引用的所有UIMA类型描述符。一个示例types.txt文件如下所示:
classpath*:org/apache/uima/fit/type/Token.xml这告诉uimaFIT加载位于包org.apache.uima.fit.type中的类型描述符文件Token.xml (用您自己的包和文件名替换)。
注意,如果使用Maven,这些文件和文件夹通常必须在src/main/resources下(而不是在src/main/java下)。取决于你如何设置你的等级,这可能也适用于你。
uimaFIT的类型自动检测在uimaFIT文档中也有更详细的描述.
因此,对于您的特殊情况:尝试将desc/type/HeidelTime_TypeSystem.xml放入src/main/resources/desc/type/HeidelTime_TypeSystem.xml并使用内容classpath*:desc/type/HeidelTime_TypeSystem.xml创建src/main/resources/META-INF/org.apache.uima.fit/types.txt文件。
注意:在撰写本文时,我是Apache uimaFIT的维护者。
https://stackoverflow.com/questions/56149592
复制相似问题