spaCy/tests/test_emoticons.py

42 lines
1.2 KiB
Python
Raw Normal View History

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-30 13:34:09 +03:00
return English()
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-21 12:43:27 +03:00
def test_false_positive(EN):
text = "example:)"
2014-12-21 12:43:27 +03:00
tokens = EN(text)
assert len(tokens) == 3