Added regression text for 1494

This commit is contained in:
Felix Sonntag 2017-11-19 16:29:04 +01:00
parent ada4712250
commit 8be3392302

View File

@ -0,0 +1,27 @@
# coding: utf8
from __future__ import unicode_literals
import pytest
import re
from ...lang.en import English
from ...tokenizer import Tokenizer
def test_issue1494():
infix_re = re.compile(r'''[^a-z]''')
text_to_tokenize = 'token 123test'
expected_tokens = ['token', '1', '2', '3', 'test']
def my_tokenizer(nlp):
return Tokenizer(nlp.vocab,
{},
infix_finditer=infix_re.finditer
)
nlp = English()
nlp.tokenizer = my_tokenizer(nlp)
tokenized_words = [token.text for token in nlp(text_to_tokenize)]
print(tokenized_words)
assert tokenized_words == expected_tokens