【问题标题】:extract noun phrase "String" from a stanford constituency parse tree从斯坦福选区分析树中提取名词短语“字符串”
【发布时间】:2015-04-03 11:24:25
【问题描述】:

如何在没有POS tags 的情况下从选区解析树中提取名词短语String / Text

我能够在不解析注释的情况下提取名词短语,但无法找到仅提取该名词短语文本的方法。 例如:

String some_sentence = "The dog ran after the intruding bigger dog";
parse Tree :**(ROOT (S (NP (DT The) (NN dog)) (VP (VBD ran) (PP (IN after) (NP (DT the) (JJ intruding) (JJR bigger) (NN dog))))))

我可以从这个解析树(NP (DT The) (NN dog))" and "(NP (DT the) (JJ intruding) 中提取以下名词短语,但我只需要这些名词短语的文本作为 The dog" 和 "the intruding

我尝试使用 Tree 类的 yieldWords() 方法构造短语,但它不能保证源字符串的精确再现,因为可能存在空格、符号等问题。

有没有办法从 Parse 树中获取准确的源字符串??

【问题讨论】:

  • 您是使用 Stanford CoreNLP 管道还是直接使用 Stanford Parser?
  • 我正在使用斯坦福 CoreNLP 管道进行解析。

标签: stanford-nlp text-parsing string-parsing


【解决方案1】:

你在正确的轨道上。使用Tree.yieldWords 提取出让词列表后,您可以使用Sentence.listToOriginalTextString 生成原始句子子字符串。

我相信这种方法是 CoreNLP 3.5.2 中的新方法,因此请确保您安装了最新版本。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-14
    • 2016-02-17
    • 1970-01-01
    • 1970-01-01
    • 2017-03-09
    • 1970-01-01
    • 2014-04-20
    • 1970-01-01
    相关资源
    最近更新 更多