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

52 Views Asked by At

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

1

There are 1 best solutions below

0
aab On

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)