mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 17:36:30 +03:00
db55577c45
* Remove unicode declarations * Remove Python 3.5 and 2.7 from CI * Don't require pathlib * Replace compat helpers * Remove OrderedDict * Use f-strings * Set Cython compiler language level * Fix typo * Re-add OrderedDict for Table * Update setup.cfg * Revert CONTRIBUTING.md * Revert lookups.md * Revert top-level.md * Small adjustments and docs [ci skip]
27 lines
709 B
Python
27 lines
709 B
Python
from spacy.lang.en import English
|
|
from ..util import make_tempdir
|
|
|
|
|
|
def test_issue3959():
|
|
""" Ensure that a modified pos attribute is serialized correctly."""
|
|
nlp = English()
|
|
doc = nlp(
|
|
"displaCy uses JavaScript, SVG and CSS to show you how computers understand language"
|
|
)
|
|
assert doc[0].pos_ == ""
|
|
|
|
doc[0].pos_ = "NOUN"
|
|
assert doc[0].pos_ == "NOUN"
|
|
|
|
# usually this is already True when starting from proper models instead of blank English
|
|
doc.is_tagged = True
|
|
|
|
with make_tempdir() as tmp_dir:
|
|
file_path = tmp_dir / "my_doc"
|
|
doc.to_disk(file_path)
|
|
|
|
doc2 = nlp("")
|
|
doc2.from_disk(file_path)
|
|
|
|
assert doc2[0].pos_ == "NOUN"
|