MauiKeywordAnnotator extends JCasAnnotator_ImplBase { @Override public void process(JCas aJCas) throws AnalysisEngineProcessException { modelProvider.configure(aJCas.getCas()); ArrayList<Topic> topics; try { MauiWrapper wrapper = modelProvider.getResource(); topics = wrapper.extractTopicsFromText(aJCas.getDocumentText(), maxTopics); } catch (MauiFilterException e) { throw new AnalysisEngineProcessException(e); } for (Topic t : topics) { if (t.getProbability() < scoreThreshold) { continue; } MetaDataStringField mdf = new MetaDataStringField(aJCas); mdf.setKey("http: mdf.setValue(t.getTitle()); mdf.addToIndexes(); } }  @Override void initialize(UimaContext aContext); @Override void process(JCas aJCas); static final String PARAM_LANGUAGE; static final String PARAM_VARIANT; static final String PARAM_MODEL_LOCATION; static final String PARAM_VOCABULARY_LOCATION; static final String PARAM_VOCABULARY_FORMAT; static final String PARAM_VOCABULARY_ENCODING; static final String PARAM_SCORE_THRESHOLD; static final String PARAM_MAX_TOPICS; }
@Test public void test() throws Exception { CollectionReader reader = createReader( TextReader.class, TextReader.PARAM_SOURCE_LOCATION, "src/test/resources/texts/input.txt", TextReader.PARAM_LANGUAGE, "en"); AnalysisEngine annotator = createEngine( MauiKeywordAnnotator.class, MauiKeywordAnnotator.PARAM_MODEL_LOCATION, "src/test/resources/fao30.model.gz"); JCas jcas = JCasFactory.createJCas(); reader.getNext(jcas.getCas()); annotator.process(jcas); List<String> keywords = select(jcas, MetaDataStringField.class).stream() .filter(m -> "http: .map(MetaDataStringField::getValue) .sorted() .collect(Collectors.toList()); assertThat(keywords).containsExactly("standards"); }