<s> """<STR_LIT>""" <EOL> import unittest <EOL> from sulci . base import Token , Sample <EOL> from sulci . textmining import Stemm <EOL> __all__ = [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> class TokenInitTest ( unittest . TestCase ) : <EOL> def test_should_create_a_token ( self ) : <EOL> token = Token ( "<STR_LIT>" , original = "<STR_LIT>" ) <EOL> self . assertTrue ( isinstance ( token , Token ) ) <EOL> def test_should_define_verified_tag_and_lemme ( self ) : <EOL> token = Token ( "<STR_LIT>" , original = "<STR_LIT>" ) <EOL> self . assertEqual ( token . verified_tag , "<STR_LIT>" ) <EOL> self . assertEqual ( token . verified_lemme , "<STR_LIT>" ) <EOL> def test_should_define_default_verified_lemme ( self ) : <EOL> token = Token ( "<STR_LIT>" , original = "<STR_LIT>" ) <EOL> self . assertEqual ( token . verified_tag , "<STR_LIT>" ) <EOL> self . assertEqual ( token . verified_lemme , "<STR_LIT>" ) <EOL> class TokenIsStrongPunctuationTest ( unittest . TestCase ) : <EOL> def test_period_is_strong_punctuation ( self ) : <EOL> token = Token ( "<STR_LIT>" , "<STR_LIT:.>" ) <EOL> self . assertTrue ( token . is_strong_punctuation ( ) ) <EOL> def test_question_mark_is_strong_punctuation ( self ) : <EOL> token = Token ( "<STR_LIT>" , "<STR_LIT:?>" ) <EOL> self . assertTrue ( token . is_strong_punctuation ( ) ) <EOL> def test_exclamation_point_is_strong_punctuation ( self ) : <EOL> token = Token ( "<STR_LIT>" , "<STR_LIT:!>" ) <EOL> self . assertTrue ( token . is_strong_punctuation ( ) ) <EOL> def test_comma_is_not_strong_punctuation ( self ) : <EOL> token = Token ( "<STR_LIT>" , "<STR_LIT:U+002C>" ) <EOL> self . assertFalse ( token . is_strong_punctuation ( ) ) <EOL> class InSampleTokenBaseTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> sentence = Sample ( "<STR_LIT>" ) <EOL> self . first = Token ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> sentence . append ( self . first ) <EOL> self . second = Token ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> sentence . append ( self . second ) <EOL> self . third = Token ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> sentence . append ( self . third ) <EOL> class TokenGetNeighborsTest ( InSampleTokenBaseTest ) : <EOL> def test_should_return_neighbors ( self ) : <EOL> neighbors = self . second . get_neighbors ( - <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> self . assertEqual ( neighbors [ <NUM_LIT:0> ] , self . first ) <EOL> self . assertEqual ( neighbors [ <NUM_LIT:1> ] , self . third ) <EOL> neighbors = self . first . get_neighbors ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> self . assertEqual ( neighbors [ <NUM_LIT:0> ] , self . second ) <EOL> self . assertEqual ( neighbors [ <NUM_LIT:1> ] , self . third ) <EOL> neighbors = self . third . get_neighbors ( - <NUM_LIT:1> , - <NUM_LIT:2> ) <EOL> self . assertEqual ( neighbors [ <NUM_LIT:0> ] , self . second ) <EOL> self . assertEqual ( neighbors [ <NUM_LIT:1> ] , self . first ) <EOL> def test_should_return_empty_list ( self ) : <EOL> neighbors = self . second . get_neighbors ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> self . assertEqual ( neighbors , [ ] ) <EOL> class TokenNeighborsBigramTest ( InSampleTokenBaseTest ) : <EOL> def test_should_get_previous_bigram ( self ) : <EOL> self . assertEqual ( self . third . previous_bigram , [ self . first , self . second ] ) <EOL> def test_should_not_get_previous_bigram ( self ) : <EOL> self . assertEqual ( self . second . previous_bigram , None ) <EOL> def test_should_get_next_bigram ( self ) : <EOL> self . assertEqual ( self . first . next_bigram , [ self . second , self . third ] ) <EOL> def test_should_not_get_next_bigram ( self ) : <EOL> self . assertEqual ( self . second . next_bigram , None ) <EOL> class TokenComparisonTests ( unittest . TestCase ) : <EOL> def test_could_compare_with_other_token ( self ) : <EOL> token1 = Token ( "<STR_LIT>" , original = "<STR_LIT>" ) <EOL> token2 = Token ( "<STR_LIT>" , original = "<STR_LIT>" ) <EOL> token3 = Token ( "<STR_LIT>" , original = "<STR_LIT>" ) <EOL> self . assertTrue ( token1 == token2 ) <EOL> self . assertTrue ( token2 == token1 ) <EOL> self . assertFalse ( token1 == token3 ) <EOL> self . assertFalse ( token3 == token1 ) <EOL> def test_could_compare_with_string ( self ) : <EOL> token = Token ( "<STR_LIT>" , original = "<STR_LIT>" ) <EOL> self . assertTrue ( token == "<STR_LIT>" ) <EOL> self . assertTrue ( "<STR_LIT>" == token ) <EOL> self . assertFalse ( token == "<STR_LIT>" ) <EOL> def test_could_compare_a_stemme ( self ) : <EOL> token1 = Token ( "<STR_LIT>" , original = "<STR_LIT>" ) <EOL> token2 = Token ( "<STR_LIT>" , original = "<STR_LIT>" ) <EOL> token3 = Token ( "<STR_LIT>" , original = "<STR_LIT>" ) <EOL> stemme1 = Stemm ( "<STR_LIT>" , text = None ) <EOL> stemme2 = Stemm ( "<STR_LIT>" , text = None ) <EOL> stemme1 . occurrences . append ( token1 ) <EOL> stemme2 . occurrences . append ( token3 ) <EOL> self . assertTrue ( token2 == stemme1 ) <EOL> self . assertFalse ( token2 == stemme2 ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
