mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-10 19:57:17 +03:00
parent
89bfd06fbd
commit
f0d8309a28
|
@ -5,7 +5,7 @@ repos:
|
||||||
- id: black
|
- id: black
|
||||||
language_version: python3.7
|
language_version: python3.7
|
||||||
additional_dependencies: ['click==8.0.4']
|
additional_dependencies: ['click==8.0.4']
|
||||||
- repo: https://gitlab.com/pycqa/flake8
|
- repo: https://github.com/pycqa/flake8
|
||||||
rev: 5.0.4
|
rev: 5.0.4
|
||||||
hooks:
|
hooks:
|
||||||
- id: flake8
|
- id: flake8
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
|
import os
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from spacy.attrs import IS_ALPHA, LEMMA, ORTH
|
from spacy.attrs import IS_ALPHA, LEMMA, ORTH
|
||||||
|
from spacy.lang.en import English
|
||||||
from spacy.parts_of_speech import NOUN, VERB
|
from spacy.parts_of_speech import NOUN, VERB
|
||||||
from spacy.vocab import Vocab
|
from spacy.vocab import Vocab
|
||||||
|
|
||||||
|
from ..util import make_tempdir
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.issue(1868)
|
@pytest.mark.issue(1868)
|
||||||
def test_issue1868():
|
def test_issue1868():
|
||||||
|
@ -59,3 +64,19 @@ def test_vocab_api_contains(en_vocab, text):
|
||||||
def test_vocab_writing_system(en_vocab):
|
def test_vocab_writing_system(en_vocab):
|
||||||
assert en_vocab.writing_system["direction"] == "ltr"
|
assert en_vocab.writing_system["direction"] == "ltr"
|
||||||
assert en_vocab.writing_system["has_case"] is True
|
assert en_vocab.writing_system["has_case"] is True
|
||||||
|
|
||||||
|
|
||||||
|
def test_to_disk():
|
||||||
|
nlp = English()
|
||||||
|
with make_tempdir() as d:
|
||||||
|
nlp.vocab.to_disk(d)
|
||||||
|
assert "vectors" in os.listdir(d)
|
||||||
|
assert "lookups.bin" in os.listdir(d)
|
||||||
|
|
||||||
|
|
||||||
|
def test_to_disk_exclude():
|
||||||
|
nlp = English()
|
||||||
|
with make_tempdir() as d:
|
||||||
|
nlp.vocab.to_disk(d, exclude=("vectors", "lookups"))
|
||||||
|
assert "vectors" not in os.listdir(d)
|
||||||
|
assert "lookups.bin" not in os.listdir(d)
|
||||||
|
|
|
@ -468,9 +468,9 @@ cdef class Vocab:
|
||||||
setters = ["strings", "vectors"]
|
setters = ["strings", "vectors"]
|
||||||
if "strings" not in exclude:
|
if "strings" not in exclude:
|
||||||
self.strings.to_disk(path / "strings.json")
|
self.strings.to_disk(path / "strings.json")
|
||||||
if "vectors" not in "exclude":
|
if "vectors" not in exclude:
|
||||||
self.vectors.to_disk(path, exclude=["strings"])
|
self.vectors.to_disk(path, exclude=["strings"])
|
||||||
if "lookups" not in "exclude":
|
if "lookups" not in exclude:
|
||||||
self.lookups.to_disk(path)
|
self.lookups.to_disk(path)
|
||||||
|
|
||||||
def from_disk(self, path, *, exclude=tuple()):
|
def from_disk(self, path, *, exclude=tuple()):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user