@Override public void process(JCas jCas) throws AnalysisEngineProcessException { beforeProcess(jCas); try { for (AnnotationFS anno : JCasUtil.select(jCas, annotationType)) { List<String> lemmas = Lists.newLinkedList(); for (Token token : JCasUtil.selectCovered(jCas, Token.class, anno)) { Word w = token2WordIdx.get(token); if (w == null) { lemmas.add(token.getCoveredText()); } else { lemmas.add(MorphCasUtils.getOnlyWordform(w).getLemma()); } } outEntries.add(lemmaJoiner.join(lemmas)); } } finally { afterProcess(jCas); } }
private void beforeProcess(JCas jCas) { token2WordIdx = MorphCasUtils.getToken2WordIndex(jCas); }