I have been searching for examples of using Apache UIMA in a java program. Are there examples on how to use the example Annotators in a Java program ?
解决方案
If you want to use UIMA directly into Java code, you might want to have a look at uimafit, because it eases the use of UIMA from within Java. Here is a quick example to use the example Annotator (source)
public class RoomNumberAnnotatorPipeline {
public static void main(String[] args) throws UIMAException {
String text = "The meeting was moved from Yorktown 01-144 to Hawthorne 1S-W33.";
TypeSystemDescription tsd = createTypeSystemDescription(
"org.uimafit.examples.tutorial.type.RoomNumber");
JCas jCas = createJCas(tsd);
jCas.setDocumentText(text);
AnalysisEngine analysisEngine = createPrimitive(RoomNumberAnnotator.class, tsd);
analysisEngine.process(jCas);
for (RoomNumber roomNumber : select(jCas, RoomNumber.class)) {
System.out.println(roomNumber.getCoveredText() + "\tbuilding = "
+ roomNumber.getBuilding());
}
}
}