The Ocelot
The Ocelot

Reputation: 1

Using Displacy, is it possible eliminate a specific dependency arrow from being rendered?

Image of Dependency Tree

1

Considering the image above, I would like to have the xcomp arrow to be removed when rendered, is it possible to do this kind of customization?

I understood how to change its style, but not how to suppress relationships if needed (for educational purposes).

Upvotes: 0

Views: 61

Answers (1)

aab
aab

Reputation: 11484

Unset the dependency label in the underlying parse:

import spacy

nlp = spacy.load("en_core_web_sm")
doc = nlp("This is a sentence")
for token in doc:
    if token.dep_ == "nsubj":
        token.dep_ = ""
spacy.displacy.serve(doc)

Upvotes: 0

Related Questions