* Add get() function in spacy/syntax/Config

This commit is contained in:
Matthew Honnibal 2015-06-07 19:09:15 +02:00
parent ac422492cf
commit 731e5f1e46
1 changed files with 3 additions and 0 deletions

View File

@ -6,6 +6,9 @@ class Config(object):
for key, value in kwargs.items(): for key, value in kwargs.items():
setattr(self, key, value) setattr(self, key, value)
def get(self, attr, default=None):
return self.__dict__.get(attr, default)
@classmethod @classmethod
def write(cls, model_dir, name, **kwargs): def write(cls, model_dir, name, **kwargs):
open(path.join(model_dir, '%s.json' % name), 'w').write(json.dumps(kwargs)) open(path.join(model_dir, '%s.json' % name), 'w').write(json.dumps(kwargs))