2012-09-22 9 views
5

Dưới đây là ví dụ về cây phân tích cú pháp phụ thuộc.Phụ thuộc phân tích trực quan cây trên trang web

Dependency Parsing Tree

Tôi muốn hình dung nó trên trang web html, bất kỳ ai có thể chỉ cho tôi một số ví dụ hoặc hướng? Tôi quen thuộc với C/C++, Python, nhưng không quen thuộc với html/javascript.

Rất cám ơn!

Trả lời

4

Covert đầu ra vào json và vượt qua nó để một số thư viện js đồ thị như d3, raphael, vv

Demo & Reference

Ví dụ Parse tree cho

"Tôi sẽ làm gì một hội thảo về NLP tại SXSW ở Austin. "

sẽ

(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)))))))) 
    (. .))) 

có thể được chuyển thành

[{ 
    "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.

2

Bạn sẽ có thể làm điều đó bằng Raphaël JS

Nhìn vào bản demo họ đã đưa lên, cho ví dụ: những người với những đường cong vv .. Điều đó sẽ chỉ cho bạn đi đúng hướng.

LƯU Ý: Ở trên sẽ vẫn yêu cầu bạn mã hóa nó trong JS, nhưng chọn JS rất thẳng về phía trước. Bạn có thể bắt đầu thẳng với Raphael và nhặt các bộ phận khi bạn đi.

Chúc may mắn.