spacy svg file vs. dependency input #8701
-
Hi, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi! There's not really an easy way to convert the exported spaCy/spacy/displacy/render.py Line 36 in f9fd288 In theory, you could of course write a function that reverses the exact calculation here, but it's probably a hassle. But if you don't have the original input, you could still reconstruct it from the visualization: the words are the tokens, and their start and end character offsets are the character positions are the offset + the length of the word + whitespace. The head of a token is the index of the token that points to it via the arrow. And the dependency label is the label of that arrow. |
Beta Was this translation helpful? Give feedback.
Hi! There's not really an easy way to convert the exported
.svg
back to the original token format – in order to generate the arcs, the heads/deps information is converted to cubic bezier curves, and the tokens are converted to<text>
elements. You can see the implementation here:spaCy/spacy/displacy/render.py
Line 36 in f9fd288
In theory, you could of course write a function that reverses the exact calculation here, but it's probably a hassle. But if you don't have the original input, you could still reconstruct it from the visualization: the words are the tokens, and their start and end character offsets are the character positions are the off…