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