* Write serializer freqs to single file, vocab/serializer.json

This commit is contained in:
Matthew Honnibal 2015-07-23 01:15:25 +02:00
parent a0e36e8efc
commit 680bb47b55

View File

@ -153,15 +153,14 @@ class English(object):
self.tagger.model.end_training() self.tagger.model.end_training()
self.vocab.strings.dump(path.join(data_dir, 'vocab', 'strings.txt')) self.vocab.strings.dump(path.join(data_dir, 'vocab', 'strings.txt'))
packer = Packer(self.vocab, [ with open(path.join(data_dir, 'vocab', 'serializer.json'), 'w') as file_:
(TAG, self.tagger.moves.freqs[TAG].items()), file_.write(
(HEAD, self.parser.moves.freqs[HEAD].items()), json.dumps([
(TAG, self.tagger.freqs[TAG].items()),
(DEP, self.parser.moves.freqs[DEP].items()), (DEP, self.parser.moves.freqs[DEP].items()),
(ENT_IOB, self.entity.moves.freqs[ENT_IOB].items()), (ENT_IOB, self.entity.moves.freqs[ENT_IOB].items()),
(ENT_TYPE, self.entity.moves.freqs[ENT_TYPE].items()) (ENT_TYPE, self.entity.moves.freqs[ENT_TYPE].items()),
]) (HEAD, self.parser.moves.freqs[HEAD].items())]))
packer.dump(path.join(data_dir, 'vocab'))
@property @property
def tags(self): def tags(self):