2017-10-20 14:49:36 +00:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2017-10-24 12:25:49 +00:00
|
|
|
from ...vocab import Vocab
|
|
|
|
from ...lang.lex_attrs import LEX_ATTRS
|
|
|
|
from ...tokens import Doc
|
|
|
|
from ...matcher import Matcher
|
2017-10-20 14:49:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_issue1434():
|
|
|
|
'''Test matches occur when optional element at end of short doc'''
|
|
|
|
vocab = Vocab(lex_attr_getters=LEX_ATTRS)
|
|
|
|
hello_world = Doc(vocab, words=['Hello', 'World'])
|
|
|
|
hello = Doc(vocab, words=['Hello'])
|
|
|
|
|
|
|
|
matcher = Matcher(vocab)
|
|
|
|
matcher.add('MyMatcher', None,
|
|
|
|
[ {'ORTH': 'Hello' }, {'IS_ALPHA': True, 'OP': '?'} ])
|
|
|
|
|
|
|
|
matches = matcher(hello_world)
|
|
|
|
assert matches
|
|
|
|
matches = matcher(hello)
|
|
|
|
assert matches
|