2015-04-07 02:52:25 +00:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
2015-04-19 19:39:18 +00:00
|
|
|
|
2015-07-24 02:51:53 +00:00
|
|
|
@pytest.mark.models
|
2015-06-07 16:02:24 +00:00
|
|
|
def test_am_pm(en_nlp):
|
2015-04-07 02:52:25 +00:00
|
|
|
numbers = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']
|
|
|
|
variants = ['a.m.', 'am', 'p.m.', 'pm']
|
|
|
|
spaces = ['', ' ']
|
|
|
|
for num in numbers:
|
|
|
|
for var in variants:
|
|
|
|
for space in spaces:
|
|
|
|
string = u"The meeting was at %s%s%s wasn't it?" % (num, space, var)
|
2015-06-07 16:02:24 +00:00
|
|
|
tokens = en_nlp(string, merge_mwes=True)
|
2015-04-07 02:52:25 +00:00
|
|
|
assert tokens[4].orth_ == '%s%s%s' % (num, space, var)
|
|
|
|
ents = list(tokens.ents)
|
2015-07-24 02:51:53 +00:00
|
|
|
assert len(ents) == 1, ents
|
2015-04-07 02:52:25 +00:00
|
|
|
assert ents[0].label_ == 'TIME', string
|
|
|
|
if ents[0].start == 4 and ents[0].end == 5:
|
|
|
|
assert ents[0].orth_ == '%s%s%s' % (num, space, var)
|