children of children seem to disappear? #6298
-
|
Hello there, I think I may have found a bug (if not, I apologize in advance!) that prevents me from accessing children of children. Please consider the following example where I am trying to extract VPs by iterating over the As you can see from the output, it looks like the children of the children are not accessible anymore. Is this a bug? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
No, this isn't a bug. Most of the |
Beta Was this translation helpful? Give feedback.
No, this isn't a bug.
Token.childrenreturns a generator, not a list, so when you try to iterate over it the second time it's empty.Most of the
DocandTokenproperties that can potentially end up iterating over a lot of data return generators rather than lists. But to be honest some of the details aren't quite 100% consistent in the API (Doc.entsreturns a tuple whileDoc.sentsreturns a generator), so it can be a good idea to check the docs to be sure: https://spacy.io/api/token#children