mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-14 13:47:13 +03:00
16 lines
450 B
Python
16 lines
450 B
Python
|
from os import path
|
||
|
import json
|
||
|
|
||
|
class Config(object):
|
||
|
def __init__(self, **kwargs):
|
||
|
for key, value in kwargs.items():
|
||
|
setattr(self, key, value)
|
||
|
|
||
|
@classmethod
|
||
|
def write(cls, model_dir, name, **kwargs):
|
||
|
open(path.join(model_dir, '%s.json' % name), 'w').write(json.dumps(kwargs))
|
||
|
|
||
|
@classmethod
|
||
|
def read(cls, model_dir, name):
|
||
|
return cls(**json.load(open(path.join(model_dir, '%s.json' % name))))
|