0

我正在尝试建立一个管道,它会产生词形还原的句子。我知道如何获得所有句子或所有引理,但我不知道如何获得引理集合除以句子结尾。这是一个缺少参数的代码片段,标记为??????

AnalysisEngine pipeline = createEngine(createEngineDescription( 
                              createEngineDescription(BreakIteratorSegmenter.class),
                              createEngineDescription(StanfordLemmatizer.class),
                              createEngineDescription(StopWordRemover.class, StopWordRemover.PARAM_MODEL_LOCATION,
                                  new String[]{"stopwords.txt"})));

JCas jcas = JCasFactory.createJCas();

jcas.setDocumentText    ("Almost all energy on Earth comes from the Sun. Plants make food energy from sunlight.");
jcas.setDocumentLanguage("en");
pipeline.process        (jcas);

for (Sentence s : select(jcas, Sentence.class)) {
  out.println("");

  for (Lemma l : select(??????, Lemma.class)) 
    out.print(l.getValue() + " ");
}

我需要在此代码中更改什么,因此它从两行中的两个输入句子中打印引理。

4

1 回答 1

2

干得好:

for (Lemma l : JCasUtil.selectCovered(Lemma.class, s)) 
    out.print(l.getValue() + " ");

披露:我正在研究 Apache UIMA 项目

于 2015-11-29T15:13:11.577 回答