下面是一个依赖关系解析树的例子。
我想把它可视化到html网页上,有没有人能给我看一些例子或说明?我熟悉C/C++,Python,但不熟悉html/javascript。
非常感谢!
发布于 2015-04-13 02:28:25
将输出转换为json,并将其传递给一些js图形库,如d3、raphael等。
Demo & Reference
例如,解析树用于
“我将在奥斯汀的SXSW做一个关于自然语言处理的研讨会。”
将会是
(ROOT
(S
(NP (PRP I))
(VP (VBP am)
(VP (VBG going)
(S
(VP (TO to)
(VP (VB do)
(NP
(NP (DT a) (NN seminar))
(PP (IN on)
(NP (NNP NLP))))
(PP (IN at)
(NP (NNP SXSW)))
(PP (IN in)
(NP (NNP Austin))))))))
(. .)))
可以转换为
[{
"data": {
"type": "ROOT"
},
"children": [{
"data": {
"type": "S"
},
"children": [{
"data": {
"type": "NP"
},
"children": [{
"data": {
"type": "PRP"
},
"children": [{
"data": {
"ne": "O",
"word": "I",
"type": "TK",
"pos": "PRP"
},
"children": []
}]
}]
}, {
"data": {
"type": "VP"
},
"children": [{
"data": {
"type": "VBP"
},
"children": [{
"data": {
"ne": "O",
"word": "am",
"type": "TK",
"pos": "VBP"
},
"children": []
}]
}, {
"data": {
"type": "VP"
},
"children": [{
"data": {
"type": "VBG"
},
"children": [{
"data": {
"ne": "O",
"word": "going",
"type": "TK",
"pos": "VBG"
},
"children": []
}]
}, {
"data": {
"type": "S"
},
"children": [{
"data": {
"type": "VP"
},
"children": [{
"data": {
"type": "TO"
},
"children": [{
"data": {
"ne": "O",
"word": "to",
"type": "TK",
"pos": "TO"
},
"children": []
}]
}, {
"data": {
"type": "VP"
},
"children": [{
"data": {
"type": "VB"
},
"children": [{
"data": {
"ne": "O",
"word": "do",
"type": "TK",
"pos": "VB"
},
"children": []
}]
}, {
"data": {
"type": "NP"
},
"children": [{
"data": {
"type": "NP"
},
"children": [{
"data": {
"type": "DT"
},
"children": [{
"data": {
"ne": "O",
"word": "a",
"type": "TK",
"pos": "DT"
},
"children": []
}]
}, {
"data": {
"type": "NN"
},
"children": [{
"data": {
"ne": "O",
"word": "seminar",
"type": "TK",
"pos": "NN"
},
"children": []
}]
}]
}, {
"data": {
"type": "PP"
},
"children": [{
"data": {
"type": "IN"
},
"children": [{
"data": {
"ne": "O",
"word": "on",
"type": "TK",
"pos": "IN"
},
"children": []
}]
}, {
"data": {
"type": "NP"
},
"children": [{
"data": {
"type": "NN"
},
"children": [{
"data": {
"ne": "ORGANIZATION",
"word": "NLP",
"type": "TK",
"pos": "NN"
},
"children": []
}]
}]
}]
}]
}, {
"data": {
"type": "PP"
},
"children": [{
"data": {
"type": "IN"
},
"children": [{
"data": {
"ne": "O",
"word": "at",
"type": "TK",
"pos": "IN"
},
"children": []
}]
}, {
"data": {
"type": "NP"
},
"children": [{
"data": {
"type": "NNP"
},
"children": [{
"data": {
"ne": "ORGANIZATION",
"word": "SXSW",
"type": "TK",
"pos": "NNP"
},
"children": []
}]
}]
}]
}, {
"data": {
"type": "PP"
},
"children": [{
"data": {
"type": "IN"
},
"children": [{
"data": {
"ne": "O",
"word": "in",
"type": "TK",
"pos": "IN"
},
"children": []
}]
}, {
"data": {
"type": "NP"
},
"children": [{
"data": {
"type": "NNP"
},
"children": [{
"data": {
"ne": "LOCATION",
"word": "Austin",
"type": "TK",
"pos": "NNP"
},
"children": []
}]
}]
}]
}]
}]
}]
}]
}]
}, {
"data": {
"type": "."
},
"children": [{
"data": {
"ne": "O",
"word": ".",
"type": "TK",
"pos": "."
},
"children": []
}]
}]
}]
}]
和can be drawn using d3。
发布于 2012-09-22 20:53:15
您应该能够使用Raphaël JS做到这一点
看看他们发布的演示,例如:那些有曲线的等等。这应该会给你指明正确的方向。
注意:上面的代码仍然需要你用JS编写,但是选择JS是非常直接的。你也许可以直接从拉斐尔开始,然后边走边学。
祝好运。
https://stackoverflow.com/questions/12543911
复制相似问题