mirror of https://github.com/explosion/spaCy.git
Use compat.json_dumps
This commit is contained in:
parent
2ab394d655
commit
f62b740961
|
@ -2,7 +2,6 @@
|
||||||
from __future__ import absolute_import, unicode_literals
|
from __future__ import absolute_import, unicode_literals
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
import shutil
|
import shutil
|
||||||
import ujson
|
|
||||||
|
|
||||||
from .tokenizer import Tokenizer
|
from .tokenizer import Tokenizer
|
||||||
from .vocab import Vocab
|
from .vocab import Vocab
|
||||||
|
@ -15,7 +14,7 @@ from .syntax.nonproj import PseudoProjectivity
|
||||||
from .pipeline import DependencyParser, EntityRecognizer
|
from .pipeline import DependencyParser, EntityRecognizer
|
||||||
from .syntax.arc_eager import ArcEager
|
from .syntax.arc_eager import ArcEager
|
||||||
from .syntax.ner import BiluoPushDown
|
from .syntax.ner import BiluoPushDown
|
||||||
from .compat import unicode_
|
from .compat import json_dumps
|
||||||
from .attrs import IS_STOP
|
from .attrs import IS_STOP
|
||||||
from . import attrs
|
from . import attrs
|
||||||
from . import orth
|
from . import orth
|
||||||
|
@ -197,9 +196,7 @@ class Language(object):
|
||||||
shutil.rmtree(str(directory))
|
shutil.rmtree(str(directory))
|
||||||
directory.mkdir()
|
directory.mkdir()
|
||||||
with (directory / 'config.json').open('wb') as file_:
|
with (directory / 'config.json').open('wb') as file_:
|
||||||
data = ujson.dumps(config, indent=2)
|
data = json_dumps(config)
|
||||||
if isinstance(data, unicode_):
|
|
||||||
data = data.encode('utf8')
|
|
||||||
file_.write(data)
|
file_.write(data)
|
||||||
if not (path / 'vocab').exists():
|
if not (path / 'vocab').exists():
|
||||||
(path / 'vocab').mkdir()
|
(path / 'vocab').mkdir()
|
||||||
|
|
Loading…
Reference in New Issue