Add Language.path

This commit is contained in:
ines 2017-10-25 11:57:43 +02:00
parent 4a06eddb5f
commit 3484174e48
2 changed files with 14 additions and 0 deletions

View File

@ -127,6 +127,7 @@ class Language(object):
RETURNS (Language): The newly constructed object.
"""
self._meta = dict(meta)
self._path = None
if vocab is True:
factory = self.Defaults.create_vocab
vocab = factory(self, **meta.get('vocab', {}))
@ -142,6 +143,10 @@ class Language(object):
bytes_data = self.to_bytes(vocab=False)
return (unpickle_language, (self.vocab, self.meta, bytes_data))
@property
def path(self):
return self._path
@property
def meta(self):
self._meta.setdefault('lang', self.vocab.lang)
@ -611,6 +616,7 @@ class Language(object):
if not (path / 'vocab').exists():
exclude['vocab'] = True
util.from_disk(path, deserializers, exclude)
self._path = path
return self
def to_bytes(self, disable=[], **exclude):

View File

@ -609,6 +609,14 @@ p Load state from a binary string.
| Custom meta data for the Language class. If a model is loaded,
| contains meta data of the model.
+row
+cell #[code path]
+tag-new(2)
+cell #[code Path]
+cell
| Path to the model data directory, if a model is loaded. Otherwise
| #[code None].
+h(2, "class-attributes") Class attributes
+table(["Name", "Type", "Description"])