I configured heidelTime using gradle. I am getting values however cannot iterate over the string result.
result = heidelTime.process(sentence, new Date());
JCas cas = JCasFactory.createJCas();
FSIterator it = cas.getAnnotationIndex(Timex3.type).iterator(); // Here I am getting error
Error is due to JCasImpl.class->TOP_Type getType(int i)
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;
}
I checked on github project and I see HeidelTime_TypeSystem.xml files there defining type System.
Gradle Configuration
compile group: 'com.github.heideltime', name: 'heideltime', version: '2.2.1'
compile group: 'org.apache.uima', name: 'uimaj-core', version: '2.3.1'
Stack Trace
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]
Do I need to add any files manually to make it work?
types.txt file location
This happens when a JCas class for an UIMA type is being used without the CAS being configured for this type.
The call to
scans the classpath for files called
types.txt
underMETA-INF/org.apache.uima.fit/
(so a folder calledMETA-INF
with a subfolder calledorg.apache.uima.fit
which then contains thetypes.txt
file) and loads all the UIMA type descriptors referenced inside them. An exampletypes.txt
file looks like this:This tells uimaFIT to load the type descriptor file
Token.xml
located in the packageorg.apache.uima.fit.type
(replace with your own package and file names).Note that if you use Maven, these all these files and folders must usually be under
src/main/resources
(not undersrc/main/java
). Depending on how you set up your Gradle, this might apply to you as well.uimaFIT's type auto-detection is also described in more detail in the uimaFIT documentation.
So for your particular case: try putting
desc/type/HeidelTime_TypeSystem.xml
intosrc/main/resources/desc/type/HeidelTime_TypeSystem.xml
and create thesrc/main/resources/META-INF/org.apache.uima.fit/types.txt
file with the contentclasspath*:desc/type/HeidelTime_TypeSystem.xml
.Note: At the time of writing, I am the maintainer of Apache uimaFIT.