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)