2015-07-13 124 views
0

使用斯坦福CoreNLP,我試圖解析文本使用神經網絡依賴解析器。它運行速度非常快(這就是爲什麼我要使用這個而不是LexicalizedParser),併產生高質量的依賴關係。我也有興趣從中檢索分析樹(賓州樹樣式)。所以,鑑於語法結構,我得到的根(使用root()),然後嘗試使用toOneLineString()方法打印出來。但是,root()返回樹的根節點,並帶有空/空的子節點列表。在說明或常見問題解答中,我找不到任何相關內容。斯坦福nndep得到解析樹

GrammaticalStructure gs = parser.predict(tagged); 

    // Print typed dependencies 
    System.err.println(gs); 

    // get the tree and print it out in the parenthesised form 
    TreeGraphNode tree = gs.root(); 
    System.err.println(tree.toOneLineString()); 

的這個輸出是:

ROOT-0{CharacterOffsetBeginAnnotation=-1, CharacterOffsetEndAnnotation=-1, PartOfSpeechAnnotation=null, TextAnnotation=ROOT}Typed Dependencies: 
    [nsubj(tell-5, I-1), aux(tell-5, can-2), advmod(always-4, almost-3), advmod(tell-5, always-4), root(ROOT-0, tell-5), advmod(use-8, when-6), nsubj(use-8, movies-7), advcl(tell-5, use-8), amod(dinosaurs-10, fake-9), dobj(use-8, dinosaurs-10), punct(tell-5, .-11)] 
    ROOT-0 

我怎樣才能得到解析樹嗎?

+0

你在尋找一個選區分析嗎?或者只是查看S表達式(PTB)格式的依賴關係解析? –

+0

確切地說,CFG解析與您從lex解析器獲得的解析類似。 – Claudiu

回答

0

圖我可以使用斯坦福大學提供的Shift-Reduce選區解析器。速度非常快,結果可比。