mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-13 10:46:29 +03:00
* Fix pickle problems
This commit is contained in:
parent
8c7e149ec9
commit
187960606f
|
@ -33,9 +33,7 @@ your yours yourself yourselves
|
||||||
STOPWORDS = set(w for w in STOPWORDS.split() if w)
|
STOPWORDS = set(w for w in STOPWORDS.split() if w)
|
||||||
|
|
||||||
class English(Language):
|
class English(Language):
|
||||||
def __init__(self, **kwargs):
|
lang = 'en'
|
||||||
kwargs['lang'] = 'en'
|
|
||||||
super(English, self).__init__(**kwargs)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_stop(string):
|
def is_stop(string):
|
||||||
|
|
|
@ -24,6 +24,8 @@ from .util import get_package
|
||||||
|
|
||||||
|
|
||||||
class Language(object):
|
class Language(object):
|
||||||
|
lang = None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def lower(string):
|
def lower(string):
|
||||||
return string.lower()
|
return string.lower()
|
||||||
|
@ -156,7 +158,6 @@ class Language(object):
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
data_dir=None,
|
data_dir=None,
|
||||||
lang=None,
|
|
||||||
model=None,
|
model=None,
|
||||||
vocab=None,
|
vocab=None,
|
||||||
tokenizer=None,
|
tokenizer=None,
|
||||||
|
@ -209,26 +210,33 @@ class Language(object):
|
||||||
warn("load_vectors is deprecated", DeprecationWarning)
|
warn("load_vectors is deprecated", DeprecationWarning)
|
||||||
if vocab in (None, True):
|
if vocab in (None, True):
|
||||||
self.vocab = self.default_vocab(package)
|
self.vocab = self.default_vocab(package)
|
||||||
|
self.vocab = vocab
|
||||||
if tokenizer in (None, True):
|
if tokenizer in (None, True):
|
||||||
self.tokenizer = Tokenizer.from_package(package, self.vocab)
|
self.tokenizer = Tokenizer.from_package(package, self.vocab)
|
||||||
|
self.tokenizer = tokenizer
|
||||||
if tagger in (None, True):
|
if tagger in (None, True):
|
||||||
self.tagger = Tagger.from_package(package, self.vocab)
|
tagger = Tagger.from_package(package, self.vocab)
|
||||||
|
self.tagger = tagger
|
||||||
if entity in (None, True):
|
if entity in (None, True):
|
||||||
self.entity = self.default_entity(package, self.vocab)
|
entity = self.default_entity(package, self.vocab)
|
||||||
|
self.entity = entity
|
||||||
if parser in (None, True):
|
if parser in (None, True):
|
||||||
self.parser = self.default_parser(package, self.vocab)
|
parser = self.default_parser(package, self.vocab)
|
||||||
|
self.parser = parser
|
||||||
if matcher in (None, True):
|
if matcher in (None, True):
|
||||||
self.matcher = Matcher.from_package(package, self.vocab)
|
matcher = Matcher.from_package(package, self.vocab)
|
||||||
|
self.matcher = matcher
|
||||||
|
|
||||||
def __reduce__(self):
|
def __reduce__(self):
|
||||||
args = (
|
args = (
|
||||||
None, # data_dir
|
None, # data_dir
|
||||||
|
None, # model
|
||||||
self.vocab,
|
self.vocab,
|
||||||
self.tokenizer,
|
self.tokenizer,
|
||||||
self.tagger,
|
self.tagger,
|
||||||
self.parser,
|
self.parser,
|
||||||
self.entity,
|
self.entity,
|
||||||
self.matcher,
|
self.matcher
|
||||||
)
|
)
|
||||||
return (self.__class__, args, None, None)
|
return (self.__class__, args, None, None)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user