2011-10-24 28 views
4

說提取條款我有一句話:從賓州樹庫格式的文本

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

我敢肯定,我不清楚,但基本上我想提取句子的獨立和非獨立的條款,而這些條款的小節。

+0

看到這個答案:http://stackoverflow.com/a/10401824/109618 –

回答

1

下面是從NLTK引導示範代碼(它沒有明確說明如何提取條款): http://nltk.googlecode.com/svn/trunk/doc/howto/tree.html

+0

我不明白這是如何回答這個問題的。 NLTK是一個Python工具。這個問題被標記爲關於斯坦福NLP。 –

+0

David James- NLTK是一款Python工具,用於處理由斯坦福大學NLP輸出格式的數據。有「語料庫閱讀器」類可以處理Penn Treebank等格式。 http://nltk.googlecode.com/svn/trunk/doc/howto/corpus.html – inquiryqueue

+2

此答案中的鏈接現在有密碼保護 – duhaime