Hi,
I try to call a simple UIMA ruta script from uimaFIT in java. It works in
plain UIMA but it didn't work in uimaFIT for me. Here is the script:
PACKAGE tutorial.entity;
WORDLIST MonthsList = 'month.txt';
DECLARE Month;
DECLARE Year;
DECLARE Date;
Document{-> MARKFAST(Month, MonthsList )};
NUM{REGEXP("19..|20..") -> MARK(Year,1,2)};
Month Year {-> MARK(Date,1,2)};
Here is the java code (based on Ruta doc example):
//System.out.println( "Hello World!" );
File specFile = new
File("/home/olhome/software/workspace/rutatest1/dateproject/descriptor/tutorial/entity/DateEngine.xml");
XMLInputSource in = new XMLInputSource(specFile);
ResourceSpecifier specifier = UIMAFramework.getXMLParser().
parseResourceSpecifier(in);
// for import by name... set the datapath in the ResourceManager
AnalysisEngine ae =
UIMAFramework.produceAnalysisEngine(specifier);
CAS cas = ae.newCAS();
cas.setDocumentText("This is my document. March June
December");
ae.process(cas);
JCas jcas = cas.getJCas();
for (Month month : JCasUtil.select(jcas, Month.class)) {
System.out.println(month.getCoveredText());
}
This is the pom dependencies:
<dependency>
<groupId>org.apache.uima</groupId>
<artifactId>ruta-core</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.uima</groupId>
<artifactId>uimafit-core</artifactId>
<version>2.1.0</version>
</dependency>
I have the following error:
Exception in thread "main" java.lang.Error: Unresolved compilation
problems:
Month cannot be resolved to a type
Bound mismatch: The generic method select(FSArray, Class<T>) of type
JCasUtil is not applicable for the arguments (JCas, Class<Month>). The
inferred type Month is not a valid substitute for the bounded parameter <T
extends TOP>
Month cannot be resolved to a type
at tuto.tuto_step0.App.main(App.java:51)
It seems that I am not able to correctly import types like in the maven
example. I am not so familiar with maven. I have put the DateTypeSystem.xml
in a folder called tuto under src folder and add the line
"classpath*:/tuto/DateTypeSystem.xml" in the text file
src/META-INF/org.apache.uima.fit/types.txt.
Any suggestion is welcome. Thank you.
Regards
Olivier
|