spaCy/spacy/tests/vocab/test_urlish.py

24 lines
525 B
Python
Raw Normal View History

2015-01-05 09:54:54 +03:00
from __future__ import unicode_literals
2014-11-02 16:23:04 +03:00
from spacy.orth import like_url
2014-11-02 05:21:57 +03:00
2015-04-19 22:39:18 +03:00
2014-11-02 05:21:57 +03:00
def test_basic_url():
2014-11-02 16:23:04 +03:00
assert like_url('www.google.com')
assert like_url('google.com')
assert like_url('sydney.com')
assert like_url('Sydney.edu')
assert like_url('2girls1cup.org')
2014-11-02 05:21:57 +03:00
def test_close_enough():
2014-11-02 16:23:04 +03:00
assert like_url('http://stupid')
assert like_url('www.hi')
2014-11-02 05:21:57 +03:00
def test_non_match():
2014-11-02 16:23:04 +03:00
assert not like_url('dog')
assert not like_url('1.2')
assert not like_url('1.a')
assert not like_url('hello.There')