如果要将UIMA直接用于Java代码,可能需要查看
uimafit,因为它可以简化Java中的UIMA使用.以下是使用示例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());
}
}
}