2017-01-05 15:11:31 +03:00
|
|
|
# coding: utf-8
|
2017-01-05 20:09:29 +03:00
|
|
|
"""Test that tokenizer exceptions are handled correctly."""
|
2017-01-05 15:11:31 +03:00
|
|
|
|
|
|
|
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('text', ["e.g.", "p.m.", "Jan.", "Dec.", "Inc."])
|
|
|
|
def test_tokenizer_handles_abbr(en_tokenizer, text):
|
|
|
|
tokens = en_tokenizer(text)
|
|
|
|
assert len(tokens) == 1
|
|
|
|
|
|
|
|
|
|
|
|
def test_tokenizer_handles_exc_in_text(en_tokenizer):
|
|
|
|
text = "It's mediocre i.e. bad."
|
|
|
|
tokens = en_tokenizer(text)
|
|
|
|
assert len(tokens) == 6
|
|
|
|
assert tokens[3].text == "i.e."
|
2017-03-12 15:44:20 +03:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('text', ["1am", "12a.m.", "11p.m.", "4pm"])
|
|
|
|
def test_tokenizer_handles_times(en_tokenizer, text):
|
|
|
|
tokens = en_tokenizer(text)
|
|
|
|
assert len(tokens) == 2
|
|
|
|
assert tokens[1].lemma_ in ["a.m.", "p.m."]
|