CoreNLP是斯坦福自然語言處理組開發的一款自然語言處理工具。CoreNLP可以解析文本,提取實體和關系等信息。在CoreNLP解析文本時,可以將解析結果以JSON數據格式進行輸出,其中構成樹結構的部分數據則是被許多研究者所關注的。
{ "sentences": [{ "index": 0, "parse": "(ROOT (S (NP (PRP I)) (VP (VBP am) (NP (DT a) (NN robot))) (. .)))", "basic-dependencies":[{ "dep": "ROOT", "governor": 0, "governorGloss": "ROOT", "dependent": 1, "dependentGloss": "I" }, { "dep": "am", "governor": 1, "governorGloss": "I", "dependent": 2, "dependentGloss": "robot" }, { "dep": "det", "governor": 4, "governorGloss": "robot", "dependent": 3, "dependentGloss": "a" }, { "dep": "nsubj", "governor": 2, "governorGloss": "robot", "dependent": 1, "dependentGloss": "I" }, { "dep": "dobj", "governor": 2, "governorGloss": "robot", "dependent": 4, "dependentGloss": "robot" }, { "dep": "punct", "governor": 2, "governorGloss": "robot", "dependent": 5, "dependentGloss": "." }] }] }
以上就是一個簡單的CoreNLP解析文本后,輸出的樹形JSON數據。在這個例子中,我們可以看到CoreNLP解析的是一個簡單句子:“I am a robot.”,并將其解析成為一棵樹形結構。
上一篇cmake編譯json