{"action":"created","issue":{"url":"https://api.github.com/repos/honnibal/spaCy/issues/152","labels_url":"https://api.github.com/repos/honnibal/spaCy/issues/152/labels{/name}","comments_url":"https://api.github.com/repos/honnibal/spaCy/issues/152/comments","events_url":"https://api.github.com/repos/honnibal/spaCy/issues/152/events","html_url":"https://github.com/honnibal/spaCy/issues/152","id":113531064,"number":152,"title":"(un)serializing a doc object","user":{"login":"belihub","id":713292,"avatar_url":"https://avatars.githubusercontent.com/u/713292?v=3","gravatar_id":"","url":"https://api.github.com/users/belihub","html_url":"https://github.com/belihub","followers_url":"https://api.github.com/users/belihub/followers","following_url":"https://api.github.com/users/belihub/following{/other_user}","gists_url":"https://api.github.com/users/belihub/gists{/gist_id}","starred_url":"https://api.github.com/users/belihub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/belihub/subscriptions","organizations_url":"https://api.github.com/users/belihub/orgs","repos_url":"https://api.github.com/users/belihub/repos","events_url":"https://api.github.com/users/belihub/events{/privacy}","received_events_url":"https://api.github.com/users/belihub/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-10-27T08:34:28Z","updated_at":"2015-11-01T21:59:34Z","closed_at":null,"body":"Some background: to avoid the minute or so required for spacy's initialization,  I plan to run it on a local server on my machine and pass strings to / get docs from it using zeromq. To do that, I need to serialize the doc object, and if I'm reading http://spacy.io/docs correctly, spacy has methods for that: Doc.to_bytes(doc) and Doc.from_bytes(bytearray). There's two places where spacy behaves unexpectedly, best illustrated by pasting the code - one, a TypeError:\r\n\r\n```\r\nIn [9]: mydoc = nlp(txt)\r\n\r\nIn [10]: mybs = Doc.to_bytes(mydoc)\r\n\r\nIn [11]: mynewdoc = Doc.from_bytes(mybs)\r\n    ---------------------------------------------------------------------------\r\n    TypeError                                 Traceback (most recent call last)\r\n    <ipython-input-11-eeef45863a37> in <module>()\r\n    ----> 1 mynewdoc = Doc.from_bytes(mybs)\r\n\r\nTypeError: descriptor 'from_bytes' requires a 'spacy.tokens.doc.Doc' object but received a 'bytearray'\r\n```\r\n\r\nTwo - following the code sample in http://spacy.io/docs and writing Doc(nlp.vocab).from_bytes() instead of Doc.from_bytes() removes the error message, but I get another on trying to work with the deserialized object:\r\n\r\n```\r\nIn [23]: mynewdoc = Doc(nlp.vocab).from_bytes(mybs)\r\n\r\nIn [24]: sents = [sent.orth_ for sent in mynewdoc.sents]\r\n    ---------------------------------------------------------------------------\r\n    ValueError                                Traceback (most recent call last)\r\n    <ipython-input-24-237283605709> in <module>()\r\n    ----> 1 sents = [sent.orth_ for sent in mynewdoc.sents]\r\n\r\nspacy/tokens/doc.pyx in sents (spacy/tokens/doc.cpp:7908)()\r\n\r\nValueError: sentence boundary detection requires the dependency parse, which requires data to be installed. If you haven't done so, run:\r\n    python -m spacy.en.download all\r\n    to install the data\r\n```\r\n\r\n'Sents' worked for the original doc, but throws the error above for the deserialized one.\r\nI'd appreciate someone pointing out what I'm doing wrong; using the latest version (v 0.97) of spacy.\r\n"},"comment":{"url":"https://api.github.com/repos/honnibal/spaCy/issues/comments/152868762","html_url":"https://github.com/honnibal/spaCy/issues/152#issuecomment-152868762","issue_url":"https://api.github.com/repos/honnibal/spaCy/issues/152","id":152868762,"user":{"login":"honnibal","id":8059750,"avatar_url":"https://avatars.githubusercontent.com/u/8059750?v=3","gravatar_id":"","url":"https://api.github.com/users/honnibal","html_url":"https://github.com/honnibal","followers_url":"https://api.github.com/users/honnibal/followers","following_url":"https://api.github.com/users/honnibal/following{/other_user}","gists_url":"https://api.github.com/users/honnibal/gists{/gist_id}","starred_url":"https://api.github.com/users/honnibal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/honnibal/subscriptions","organizations_url":"https://api.github.com/users/honnibal/orgs","repos_url":"https://api.github.com/users/honnibal/repos","events_url":"https://api.github.com/users/honnibal/events{/privacy}","received_events_url":"https://api.github.com/users/honnibal/received_events","type":"User","site_admin":false},"created_at":"2015-11-01T21:59:34Z","updated_at":"2015-11-01T21:59:34Z","body":"If you just want to load the vocab, you should be able to do that without loading the rest of `English`. Try:\r\n\r\n    `nlp.vocab.from_dir(path.join(English.default_data_dir(), 'vocab'))`\r\n\r\nYou could also pass things in more directly."}}