【问题标题】:How to get lemmas from sentences in DKPro/UIMA?如何从 DKPro/UIMA 中的句子中获取引理?
【发布时间】:2015-11-29 05:36:27
【问题描述】:

我正在尝试设置一个管道,该管道会生成词形还原的句子。我知道如何获得所有句子或所有引理,但我不知道如何获得引理集合除以句子结尾。这是一个带有 ?????? 标记的缺失参数的代码 sn-p:

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() + " ");
}

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

【问题讨论】:

    标签: java nlp uima dkpro-core


    【解决方案1】:

    给你:

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

    披露:我正在从事 Apache UIMA 项目

    【讨论】:

    • 谢谢,但我收到了The method selectCovered(Class<T>, AnnotationFS) in the type JCasUtil is not applicable for the arguments (Sentence, Class<Lemma>) 错误。
    • 抱歉,订单有误 - 已更新。首先是类,然后是覆盖注释。
    • 谢谢,现在可以使用了。顺便说一句,找到这种详细规范的最佳位置是什么?
    • 文档 JCas 在 UIMA Core SDK 文档中 - 所有 UIMA Core 文档都在此处链接:uima.apache.org/documentation.html
    • 要从文件中读取,您需要使用 Collection Reader。 DKPro Core 有一个 TextReader (dkpro.github.io/dkpro-core/releases/1.7.0/apidocs/index.html?de/…) - 我目前不知道有一个 epub 阅读器。 - 参见:dkpro.github.io/dkpro-core/documentation
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-17
    • 1970-01-01
    • 2015-06-27
    • 1970-01-01
    • 1970-01-01
    • 2012-04-17
    相关资源
    最近更新 更多