从 Penn Treebank 格式的文本中提取子句
假设我有一句话:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是 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