displaCy: Separating Punctuations in Dependency Visualization #13306
-
|
Firstly, I am very grateful for your open-source tool for dependency visualization. When I tested the input with separate punctuations, the generated output figure from the How can I separate punctuations in dependency visualization? The scripts that I tested and the generated output figure are also attached: import spacy
nlp = spacy.load("en_core_web_sm")
doc = nlp("The curious cat, with a fluffy tail, explored the garden.")
# Dependency Info of the input sentence.
"""
1 The the DET DT _ 3 det _ _
2 curious curious ADJ JJ _ 3 amod _ _
3 cat cat NOUN NN _ 10 nsubj _ SpaceAfter=No
4 , , PUNCT , _ 3 punct _ _
5 with with ADP IN _ 3 prep _ _
6 a a DET DT _ 8 det _ _
7 fluffy fluffy ADJ JJ _ 8 amod _ _
8 tail tail NOUN NN _ 5 pobj _ SpaceAfter=No
9 , , PUNCT , _ 3 punct _ _
10 explored explore VERB VBD _ 0 ROOT _ _
11 the the DET DT _ 12 det _ _
12 garden garden NOUN NN _ 10 dobj _ SpaceAfter=No
13 . . PUNCT . _ 10 punct _ SpaceAfter=No
"""
spacy.displacy.serve(doc, style="dep")
The output is:
 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hi! You can find the documentation for displacy's functionality here, and the docs for This will separate the punctuation tokens in the visualisation as you wanted. |
Beta Was this translation helpful? Give feedback.
Hi! You can find the documentation for displacy's functionality here, and the docs for
"dep" visualisation specifically are here. You can add options to your code like so:This will separate the punctuation tokens in the visualisation as you wanted.