spaCy/spacy/tests/stringstore/test_freeze_string_store.py

24 lines
563 B
Python
Raw Normal View History

2017-01-12 14:07:31 +00:00
# coding: utf-8
"""Test the possibly temporary workaround of flushing the stringstore of OOV words."""
from __future__ import unicode_literals
import pytest
@pytest.mark.parametrize('text', [["a", "b", "c"]])
def test_stringstore_freeze_oov(stringstore, text):
assert stringstore[text[0]] == 1
assert stringstore[text[1]] == 2
stringstore.set_frozen(True)
s = stringstore[text[2]]
assert s >= 4
s_ = stringstore[s]
assert s_ == text[2]
stringstore.flush_oov()
with pytest.raises(IndexError):
s_ = stringstore[s]