user4089193
user4089193

Reputation:

How to get the Stanford-style parse tree (with "noun phrases" and "verb phrases") in spaCy?

spaCy provides POS tagging and dependency trees. Is it possible to get what Stanford calls the "Parse" tree from it? The difference between these two trees can be seen at the Stanford parser demo at http://nlp.stanford.edu:8080/parser/index.jsp

Stanford "Parse" tree:

(ROOT
  (S
    (NP (NNP John))
    (VP (VBZ likes)
      (NP (PRP him)))
    (. .)))

Dependency tree: (Provided by spaCy and Stanford parser)

nsubj(likes-2, John-1)
root(ROOT-0, likes-2)
dobj(likes-2, him-3)

Is it possible to deduce or directly get the parse tree in spaCy? I have gone through the documentation and I couldn't find any direct API's.

Upvotes: 2

Views: 2159

Answers (1)

Mark Amery
Mark Amery

Reputation: 155125

Your terminology is a little confused, although it's largely Stanford's fault for its slightly confusing use of terms. A "parse tree" is any tree-based representation of a sentence, including both examples you've given above (i.e. a "dependency tree" is a kind of parse tree). The kind of tree that you want to get is called a "constituency tree"; the difference between them is described at Difference between constituency parser and dependency parser.

Constituency tree

(ROOT
  (S
    (NP (NNP John))
    (VP (VBZ likes)
      (NP (PRP him)))
    (. .)))

Dependency tree

nsubj(likes-2, John-1)
root(ROOT-0, likes-2)
dobj(likes-2, him-3)

Unfortunately, spaCy doesn't yet support constituency parsing. They want to eventually - there's an open issue - but as of right now the feature doesn't exist.

Upvotes: 2

Related Questions