2014-11-02 05:22:14 +03:00
|
|
|
from __future__ import unicode_literals
|
2014-12-21 12:43:27 +03:00
|
|
|
import pytest
|
2014-11-02 05:22:14 +03:00
|
|
|
|
2014-12-21 12:43:27 +03:00
|
|
|
from spacy.en import English
|
2014-11-02 05:22:14 +03:00
|
|
|
|
2014-12-21 12:43:27 +03:00
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def EN():
|
2014-12-23 03:40:32 +03:00
|
|
|
return English(tag=False)
|
2014-12-21 12:43:27 +03:00
|
|
|
|
|
|
|
def test_tweebo_challenge(EN):
|
2014-11-02 05:22:14 +03:00
|
|
|
text = u""":o :/ :'( >:o (: :) >.< XD -__- o.O ;D :-) @_@ :P 8D :1 >:( :D =| ") :> ...."""
|
2014-12-21 12:43:27 +03:00
|
|
|
tokens = EN(text)
|
2014-11-02 05:22:14 +03:00
|
|
|
assert tokens[0].string == ":o"
|
|
|
|
assert tokens[1].string == ":/"
|
|
|
|
assert tokens[2].string == ":'("
|
|
|
|
assert tokens[3].string == ">:o"
|
|
|
|
assert tokens[4].string == "(:"
|
|
|
|
assert tokens[5].string == ":)"
|
|
|
|
assert tokens[6].string == ">.<"
|
|
|
|
assert tokens[7].string == "XD"
|
|
|
|
assert tokens[8].string == "-__-"
|
|
|
|
assert tokens[9].string == "o.O"
|
|
|
|
assert tokens[10].string == ";D"
|
|
|
|
assert tokens[11].string == ":-)"
|
|
|
|
assert tokens[12].string == "@_@"
|
|
|
|
assert tokens[13].string == ":P"
|
|
|
|
assert tokens[14].string == "8D"
|
|
|
|
assert tokens[15].string == ":1"
|
|
|
|
assert tokens[16].string == ">:("
|
|
|
|
assert tokens[17].string == ":D"
|
|
|
|
assert tokens[18].string == "=|"
|
|
|
|
assert tokens[19].string == '")'
|
|
|
|
assert tokens[20].string == ':>'
|
|
|
|
assert tokens[21].string == '....'
|
2014-12-09 08:08:17 +03:00
|
|
|
|
|
|
|
|
2014-12-21 12:43:27 +03:00
|
|
|
def test_false_positive(EN):
|
2014-12-09 08:08:17 +03:00
|
|
|
text = "example:)"
|
2014-12-21 12:43:27 +03:00
|
|
|
tokens = EN(text)
|
2014-12-09 08:08:17 +03:00
|
|
|
assert len(tokens) == 3
|