From fec94330446803c808d39bf809b29f33c32f3c45 Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Fri, 4 Oct 2019 12:18:41 +0200 Subject: [PATCH] Make PhraseMatcher.vocab consistent with Matcher.vocab (closes #4373) --- spacy/matcher/phrasematcher.pxd | 2 +- spacy/tests/regression/test_issue4373.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 spacy/tests/regression/test_issue4373.py diff --git a/spacy/matcher/phrasematcher.pxd b/spacy/matcher/phrasematcher.pxd index 753b2da74..1bce70260 100644 --- a/spacy/matcher/phrasematcher.pxd +++ b/spacy/matcher/phrasematcher.pxd @@ -9,7 +9,7 @@ from ..vocab cimport Vocab cdef class PhraseMatcher: - cdef Vocab vocab + cdef readonly Vocab vocab cdef attr_id_t attr cdef object _callbacks cdef object _docs diff --git a/spacy/tests/regression/test_issue4373.py b/spacy/tests/regression/test_issue4373.py new file mode 100644 index 000000000..57d7547da --- /dev/null +++ b/spacy/tests/regression/test_issue4373.py @@ -0,0 +1,13 @@ +# coding: utf8 +from __future__ import unicode_literals + +from spacy.matcher import Matcher, PhraseMatcher +from spacy.vocab import Vocab + + +def test_issue4373(): + """Test that PhraseMatcher.vocab can be accessed (like Matcher.vocab).""" + matcher = Matcher(Vocab()) + assert isinstance(matcher.vocab, Vocab) + matcher = PhraseMatcher(Vocab()) + assert isinstance(matcher.vocab, Vocab)