Skip to content

How to use Doc.__init__ with heads #8334

Discussion options

You must be logged in to vote

Sorry you're having trouble with this.

So this should be issuing a warning or something, but if you pass heads without deps they are not used. This works the way you want it to:

import spacy
from spacy.tokens import Doc

nlp = spacy.blank("en")

doc = Doc(nlp.vocab, ["The", "cat"], heads=[1, 1], deps=["xxx", "xxx"])

for word in doc:
    print(word, word.head)

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@polm
Comment options

@pb-jeff-oneill
Comment options

Answer selected by pb-jeff-oneill
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat / parser Feature: Dependency Parser feat / doc Feature: Doc, Span and Token objects
2 participants
Converted from issue

This discussion was converted from issue #8329 on June 10, 2021 04:42.