当前位置: 首页 > 工具软件 > Apache UIMA > 使用案例 >

java中apache_在Java程序中使用Apache UIMA的示例

景永春
2023-12-01

如果要将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());

}

}

}

 类似资料: