Nlp 从Penn树库格式的文本中提取子句

Nlp 从Penn树库格式的文本中提取子句,nlp,stanford-nlp,Nlp,Stanford Nlp,假设我有一句话: After he had eaten the cheese, Bill went to the grocery. 在我的程序中,我得到以下输出: ---PARSE TREE--- (ROOT (S (SBAR (IN After) (S (NP (PRP he)) (VP (VBD had) (VP (VBN eaten) (NP (DT the) (NN cheese))))

假设我有一句话:

After he had eaten the cheese, Bill went to the grocery.
在我的程序中,我得到以下输出:

---PARSE TREE---
(ROOT
  (S
    (SBAR (IN After)
      (S
        (NP (PRP he))
        (VP (VBD had)
          (VP (VBN eaten)
            (NP (DT the) (NN cheese))))))
    (, ,)
    (NP (NNP Bill))
    (VP (VBD went)
      (PP (TO to)
        (NP (DT the) (NN grocery))))
    (. .)))
如何将不在子句中的内容合并为独立的子句?像这样:

S Clause {
    SBAR Clause {
         After he had eaten the cheese,
    }

    S Clause {
        Bill went to the grocery.
    }
}

我很确定我不清楚,但基本上我想提取句子的独立子句和从属子句,以及这些子句的子子句。

以下是NLTK指南中的演示代码(它没有明确说明如何提取子句):

我看不出这是如何回答这个问题的。NLTK是一个Python工具。David James-NLTK是一个Python工具,用于处理斯坦福NLP输出结构中格式化的数据。有一些“语料库阅读器”类可以处理诸如Penn Treebank之类的格式。此答案中的链接现在受密码保护。用户名和密码是什么?请参阅此答案: