How to save doc to disk with nlp.pipe(as.tuple = True)? #11474
-
Greetings, I am looking for a way to save for task So the question is, is there a way to save both context and |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
Also I've faced with a strange behaviour (it might be also due to my lack of knowledge) for instance,
This works like a charm! However, if I run the loop (with the very same code) for the second time, I got no results at all. Indeed, it returns blank. For instance;
or
Provides no results. So I have to rerun |
Beta Was this translation helpful? Give feedback.
-
The right way to do this depends on your access pattern. A simple thing you can do is, if the data can be serialized easily, you can put it in a custom extension attribute ( If you need random access, you'll want to serialize Docs individually, so you could just create a tuple like If you give more details about the type of data you have in "context" and what your access needs are we may be able to give better advice. |
Beta Was this translation helpful? Give feedback.
The right way to do this depends on your access pattern.
A simple thing you can do is, if the data can be serialized easily, you can put it in a custom extension attribute (
_
attribute) and use a DocBin to serialize things. However DocBins aren't designed for random access.If you need random access, you'll want to serialize Docs individually, so you could just create a tuple like
(doc, stuff)
and serialize it, with some kind of separate index structure. However that will be very inefficient due to the way Vocabs work, so if you need to do that you should copy just the parts of the Doc you need into another data structure.If you give more details about the type of data you have in "conte…