mirror of
https://github.com/explosion/spaCy.git
synced 2025-02-04 21:50:35 +03:00
Add Language.path
This commit is contained in:
parent
4a06eddb5f
commit
3484174e48
|
@ -127,6 +127,7 @@ class Language(object):
|
||||||
RETURNS (Language): The newly constructed object.
|
RETURNS (Language): The newly constructed object.
|
||||||
"""
|
"""
|
||||||
self._meta = dict(meta)
|
self._meta = dict(meta)
|
||||||
|
self._path = None
|
||||||
if vocab is True:
|
if vocab is True:
|
||||||
factory = self.Defaults.create_vocab
|
factory = self.Defaults.create_vocab
|
||||||
vocab = factory(self, **meta.get('vocab', {}))
|
vocab = factory(self, **meta.get('vocab', {}))
|
||||||
|
@ -142,6 +143,10 @@ class Language(object):
|
||||||
bytes_data = self.to_bytes(vocab=False)
|
bytes_data = self.to_bytes(vocab=False)
|
||||||
return (unpickle_language, (self.vocab, self.meta, bytes_data))
|
return (unpickle_language, (self.vocab, self.meta, bytes_data))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path(self):
|
||||||
|
return self._path
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def meta(self):
|
def meta(self):
|
||||||
self._meta.setdefault('lang', self.vocab.lang)
|
self._meta.setdefault('lang', self.vocab.lang)
|
||||||
|
@ -611,6 +616,7 @@ class Language(object):
|
||||||
if not (path / 'vocab').exists():
|
if not (path / 'vocab').exists():
|
||||||
exclude['vocab'] = True
|
exclude['vocab'] = True
|
||||||
util.from_disk(path, deserializers, exclude)
|
util.from_disk(path, deserializers, exclude)
|
||||||
|
self._path = path
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def to_bytes(self, disable=[], **exclude):
|
def to_bytes(self, disable=[], **exclude):
|
||||||
|
|
|
@ -609,6 +609,14 @@ p Load state from a binary string.
|
||||||
| Custom meta data for the Language class. If a model is loaded,
|
| Custom meta data for the Language class. If a model is loaded,
|
||||||
| contains meta data of the model.
|
| 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
|
+h(2, "class-attributes") Class attributes
|
||||||
|
|
||||||
+table(["Name", "Type", "Description"])
|
+table(["Name", "Type", "Description"])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user