Reputation: 2984
Is it possible to navigate the dependency parse tree in CoreNLP
the way one does that in spaCy
as described here? So far I see that token attributes like lemmas, POS tags, etc. are retrievable through an index, e.g. sent.lemmas(5)
returns the lemma of the sixth token. I am not sure this exists for dependency heads and relations. Is there an established way of using these apart from navigating the whole tree every time?
Upvotes: 0
Views: 495
Reputation: 5749
If you're using the regular API, I believe what you're looking for is the function:
Set<IndexedWord> SemanticGraph#vertexSet()
This iterates over all of the nodes in a dependency tree [/graph]. each IndexedWord
is also a CoreLabel
, which means it has all of the functions you know and love for tokens.
From the simple API -- which I gather is what you're using -- you can get a regular old dependency graph with:
SemanticGraph Sentence#dependencyGraph()
Upvotes: 1