2020-07-22 13:00:25 +00:00
|
|
|
import pickle
|
2023-06-14 15:48:41 +00:00
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
2020-07-22 13:00:25 +00:00
|
|
|
from spacy.morphology import Morphology
|
|
|
|
from spacy.strings import StringStore
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def morphology():
|
2020-08-07 13:27:13 +00:00
|
|
|
morphology = Morphology(StringStore())
|
|
|
|
morphology.add("Feat1=Val1|Feat2=Val2")
|
|
|
|
morphology.add("Feat3=Val3|Feat4=Val4")
|
|
|
|
return morphology
|
2020-07-22 13:00:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_morphology_pickle_roundtrip(morphology):
|
|
|
|
b = pickle.dumps(morphology)
|
|
|
|
reloaded_morphology = pickle.loads(b)
|
2020-08-09 20:36:23 +00:00
|
|
|
feat = reloaded_morphology.get(morphology.strings["Feat1=Val1|Feat2=Val2"])
|
|
|
|
assert feat == "Feat1=Val1|Feat2=Val2"
|
|
|
|
feat = reloaded_morphology.get(morphology.strings["Feat3=Val3|Feat4=Val4"])
|
|
|
|
assert feat == "Feat3=Val3|Feat4=Val4"
|