From edb71a280e5988654bcfd79b72c0fd5896e845f2 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Wed, 24 Jan 2018 15:42:33 +0100 Subject: [PATCH] Add test for #1883: Unpickling Matcher --- spacy/tests/regression/test_issue1883.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 spacy/tests/regression/test_issue1883.py diff --git a/spacy/tests/regression/test_issue1883.py b/spacy/tests/regression/test_issue1883.py new file mode 100644 index 000000000..3fcf905c1 --- /dev/null +++ b/spacy/tests/regression/test_issue1883.py @@ -0,0 +1,18 @@ +'''Check Matcher can be unpickled correctly.''' +from __future__ import unicode_literals + +import copy + +from ... vocab import Vocab +from ... matcher import Matcher +from ... tokens import Doc + + +def test_issue1883(): + m = Matcher(Vocab()) + m.add('pat1', None, [{'orth': 'hello'}]) + doc = Doc(m.vocab, words=['hello']) + assert len(m(doc)) == 1 + m2 = copy.deepcopy(m) + doc2 = Doc(m2.vocab, words=['hello']) + assert len(m2(doc2)) == 1