spaCy/tests/test_number.py

35 lines
605 B
Python
Raw Normal View History

2014-11-02 02:21:39 +00:00
from spacy.orth import like_number
2014-11-01 08:13:40 +00:00
def test_digits():
2014-11-02 02:21:39 +00:00
assert like_number('10')
assert like_number('1')
2014-11-01 08:13:40 +00:00
def test_comma():
2014-11-02 02:21:39 +00:00
assert like_number('10,000')
assert like_number('10,00')
assert like_number(',10')
2014-11-01 08:13:40 +00:00
def test_period():
2014-11-02 02:21:39 +00:00
assert like_number('999.0')
assert like_number('.99')
2014-11-01 08:13:40 +00:00
def test_fraction():
2014-11-02 02:21:39 +00:00
assert like_number('1/2')
assert not like_number('1/2/3')
2014-11-01 08:13:40 +00:00
def test_word():
2014-11-02 02:21:39 +00:00
assert like_number('one')
assert like_number('two')
assert like_number('billion')
2014-11-01 08:13:40 +00:00
def test_not_number():
2014-11-02 02:21:39 +00:00
assert not like_number('dog')
assert not like_number(',')
2014-11-01 08:13:40 +00:00