从 Penn Treebank 格式的文本中提取子句

发布于 2024-12-11 09:21:14 字数 674 浏览 0 评论 0原文

假设我有一句话:

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.
    }
}

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

Say I have a sentence:

After he had eaten the cheese, Bill went to the grocery.

In my program, I get the following output:

---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))))
    (. .)))

How would I merge the stuff not within a clause to become an independent clause? Like this:

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

    S Clause {
        Bill went to the grocery.
    }
}

I'm pretty sure that I'm not clear, but basically I want to extract the independent and dependent clauses of the sentence, and the subclauses of those clauses.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月亮坠入山谷 2024-12-18 09:21:14

这是 NLTK 指南中的演示代码(它没有明确显示如何提取子句):
http://nltk.googlecode.com/svn/trunk/doc/howto /tree.html

Here is a demonstration code from the NLTK guide (It doesn't explicitly show how to extract a clause):
http://nltk.googlecode.com/svn/trunk/doc/howto/tree.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文