小编Vin*_*mbi的帖子

如何获取DictionaryAnnotator的带注释文本

我有一个从UIMA的DictionaryCreator创建的字典,我想使用DictionaryAnnotator和上面提到的字典来注释一段文本,我无法弄清楚如何获取带注释的文本.如果你这样做,请告诉我.任何帮助表示赞赏.代码,字典文件和描述符在下面提到,PS我是Apache UIMA的新手.

 XMLInputSource xml_in = new XMLInputSource("DictionaryAnnotatorDescriptor.xml");
         ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(xml_in);
         AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier);
         JCas jCas = ae.newJCas();
         String inputText = "Mark and John went down the rabbit hole to meet a wise owl and have curry with the owl.";
         jCas.setDocumentText(inputText);
         printResults(jCas);


public static void printResults(JCas jcas) {
    FSIndex<Annotation> index = jcas.getAnnotationIndex();
    for (Iterator<Annotation> it = index.iterator(); it.hasNext(); ) {
        Annotation annotation = it.next();
        List<Feature> features;
            features = annotation.getType().getFeatures();
        List<String> fasl = new ArrayList<String>();
        for (Feature feature : features) …
Run Code Online (Sandbox Code Playgroud)

java artificial-intelligence uima opennlp uimanageddocument

0
推荐指数
1
解决办法
1363
查看次数