2012-08-24 20 views
2

如何將所有NN標籤結合使用Java結合NN標籤使用Java

nsubj(martyrdom-4, Today-1) 
cop(martyrdom-4, is-2) 
det(martyrdom-4, the-3) 
root(ROOT-0, martyrdom-4) 
nn(Mukherjee-7, Dr-6) 
prep_of(martyrdom-4, Mukherjee-7) 
det(founder-9, the-8) 
dep(tribute-17, founder-9) 

prep_of(founder-9, Jan-11) 
nn(body-15, Sangh-12) 
nn(body-15, BJP-13) 
nn(body-15, parent-14) 
dep(tribute-17, body-15) 
poss(tribute-17, My-16) 
dep(martyrdom-4, tribute-17) 
prep_to(tribute-17, him-19) 

我希望得到一個名詞短語詞組標籤形成名詞短語:

prep_of(founder-9,Jan-11) 
nn(body-15, Sangh-12) 
nn(body-15, BJP-13) 
nn(body-15, parent-14) 

輸出應該是----------> jan sangh BJP母公司

+0

相關問題:http://stackoverflow.com/questions/11985585/pharse-level-dependency-parser-using-java-nlp/ –

+0

@KenstonChoi雅一點位相同但你指出的問題是要求依賴而不是名詞性的分詞。 –

回答

1

我相信這是斯坦福分析器的依賴鏈輸出。如果是,那麼你應該已經在句子的解析樹中擁有名詞短語(NP節點)。您可以從分析樹中提取最低級別的NP節點以獲取所需的名詞短語。例如,對於句子「 今天是慕克吉博士,揚地協會的創辦人殉難BJP」,解析樹是:

(ROOT 
    (S 
    (NP (NNP Today)) 
    (VP (VBZ is) 
     (NP 
     (NP (DT the) (NN martyrdom)) 
     (PP (IN of) 
      (NP 
      (NP (NNP Dr.) (NNP Mukherjee)) 
      (, ,) 
      (NP 
       (NP (NN founder)) 
       (PP (IN of) 
       (NP (NNP Jan) (NNP Sangh) (NNP BJP)))))))) 
    (. .))) 

在這棵樹,最低含專有名詞水平的NP (NNPs)會給你所需的大多數名詞短語(所有這些都不是你需要的命名實體)。在這種情況下,輸出將是:

(NP (NNP Today)) 
(NP (NNP Dr.) (NNP Mukherjee)) 
(NP (NNP Jan) (NNP Sangh) (NNP BJP)) 
+0

如何使用java代碼 –

+0

如何使用java遍歷圖樹 –