Fix dill usage in vocab

This commit is contained in:
Matthew Honnibal 2018-12-06 18:53:16 +01:00
parent 9520489225
commit c0af627f32

View File

@ -3,7 +3,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import numpy import numpy
import dill import srsly
from collections import OrderedDict from collections import OrderedDict
from thinc.neural.util import get_array_module from thinc.neural.util import get_array_module
@ -513,7 +513,7 @@ def pickle_vocab(vocab):
morph = vocab.morphology morph = vocab.morphology
length = vocab.length length = vocab.length
data_dir = vocab.data_dir data_dir = vocab.data_dir
lex_attr_getters = dill.dumps(vocab.lex_attr_getters) lex_attr_getters = srsly.pickle_dumps(vocab.lex_attr_getters)
lexemes_data = vocab.lexemes_to_bytes() lexemes_data = vocab.lexemes_to_bytes()
return (unpickle_vocab, return (unpickle_vocab,
(sstore, vectors, morph, data_dir, lex_attr_getters, lexemes_data, length)) (sstore, vectors, morph, data_dir, lex_attr_getters, lexemes_data, length))
@ -527,7 +527,7 @@ def unpickle_vocab(sstore, vectors, morphology, data_dir,
vocab.strings = sstore vocab.strings = sstore
vocab.morphology = morphology vocab.morphology = morphology
vocab.data_dir = data_dir vocab.data_dir = data_dir
vocab.lex_attr_getters = dill.loads(lex_attr_getters) vocab.lex_attr_getters = srsly.pickle_loads(lex_attr_getters)
vocab.lexemes_from_bytes(lexemes_data) vocab.lexemes_from_bytes(lexemes_data)
vocab.length = length vocab.length = length
return vocab return vocab