From 920887f4e4ff0525f7fdce13ad285ec38bb1ad34 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 29 May 2017 13:04:40 +0200 Subject: [PATCH] Specify order of vocab deserialization --- spacy/vocab.pyx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spacy/vocab.pyx b/spacy/vocab.pyx index bc6166e39..5659d7181 100644 --- a/spacy/vocab.pyx +++ b/spacy/vocab.pyx @@ -9,6 +9,7 @@ from libc.string cimport memset, memcpy from libc.stdint cimport int32_t from libc.math cimport sqrt from cymem.cymem cimport Address +from collections import OrderedDict from .lexeme cimport EMPTY_LEXEME from .lexeme cimport Lexeme from .strings cimport hash_string @@ -304,10 +305,10 @@ cdef class Vocab: **exclude: Named attributes to prevent from being loaded. RETURNS (Vocab): The `Vocab` object. """ - setters = { - 'strings': lambda b: self.strings.from_bytes(b), - 'lexemes': lambda b: self.lexemes_from_bytes(b) - } + setters = OrderedDict(( + ('strings', lambda b: self.strings.from_bytes(b)), + ('lexemes', lambda b: self.lexemes_from_bytes(b)) + )) return util.from_bytes(bytes_data, setters, exclude) def lexemes_to_bytes(self):