Ejemplo n.º 1
0
 def test_has_uppercase_elements(self):
     target = Target({})
     actual = target.preparation("Red HEEL")
     self.assertDictEqual(
         actual,
         {
             'used_query': 'Red HEEL',
             'original_query': 'Red HEEL',
             'tokens': [
                 {
                     'start': 0,
                     'end': 3,
                     'pos': 'NNP',
                     'stem': u'red',
                     'stop_word': False,
                     'skip_word': False,
                     'use': True,
                     'value': 'red'
                 },
                 {
                     'start': 4,
                     'end': 8,
                     'pos': 'NNP',
                     'stem': u'heel',
                     'stop_word': False,
                     'skip_word': False,
                     'use': True,
                     'value': 'heel'
                 }
             ]
         }
     )
Ejemplo n.º 2
0
 def test_has_uppercase_elements(self):
     target = Target({})
     actual = target.preparation("Red HEEL")
     self.assertDictEqual(
         actual, {
             'used_query':
             'Red HEEL',
             'original_query':
             'Red HEEL',
             'tokens': [{
                 'start': 0,
                 'end': 3,
                 'pos': 'NNP',
                 'stem': u'red',
                 'stop_word': False,
                 'skip_word': False,
                 'use': True,
                 'value': 'red'
             }, {
                 'start': 4,
                 'end': 8,
                 'pos': 'NNP',
                 'stem': u'heel',
                 'stop_word': False,
                 'skip_word': False,
                 'use': True,
                 'value': 'heel'
             }]
         })
Ejemplo n.º 3
0
 def test_empty_string(self):
     target = Target({})
     actual = target.preparation("")
     self.assertDictEqual(actual, {
         'used_query': '',
         'tokens': [],
         'original_query': ''
     })
Ejemplo n.º 4
0
 def test_has_stopwords(self):
     target = Target({})
     actual = target.preparation("Shoes with red and white")
     self.assertDictEqual(
         actual,
         {
             'original_query': 'Shoes with red and white',
             'used_query': 'Shoes with red and white',
             'tokens': [
                 {
                     'start': 0,
                     'end': 5,
                     'pos': 'VBZ',
                     'stem': u'shoe',
                     'stop_word': False,
                     'skip_word': False,
                     'use': True,
                     'value': 'shoes'},
                 {
                     'start': 6,
                     'end': 10,
                     'pos': 'IN',
                     'stem': u'with',
                     'stop_word': True,
                     'skip_word': False,
                     'use': False,
                     'value': 'with'},
                 {
                     'start': 11,
                     'end': 14,
                     'pos': 'JJ',
                     'stem': u'red',
                     'stop_word': False,
                     'skip_word': False,
                     'use': True,
                     'value': 'red'},
                 {
                     'start': 15,
                     'end': 18,
                     'pos': 'CC',
                     'stem': u'and',
                     'stop_word': True,
                     'skip_word': False,
                     'use': False,
                     'value': 'and'},
                 {
                     'start': 19,
                     'end': 24,
                     'pos': 'JJ',
                     'stem': u'white',
                     'stop_word': False,
                     'skip_word': False,
                     'use': True,
                     'value': 'white'
                 }
             ]
         }
     )
Ejemplo n.º 5
0
 def test_empty_string(self):
     target = Target({})
     actual = target.preparation("")
     self.assertDictEqual(
         actual,
         {
             'used_query': '',
             'tokens': [],
             'original_query': ''
         }
     )
Ejemplo n.º 6
0
 def test_has_skipwords(self):
     target = Target({})
     actual = target.preparation("Show me anything")
     self.assertDictEqual(
         actual,
         {
             'original_query': 'Show me anything',
             'used_query': 'Show me anything',
             'tokens': [
                 {
                     'start': 0,
                     'end': 4,
                     'pos': 'NNP',
                     'stem': u'show',
                     'stop_word': True,
                     'skip_word': True,
                     'use': False,
                     'value': 'show'},
                 {
                     'start': 5,
                     'end': 7,
                     'pos': 'PRP',
                     'stem': u'me',
                     'stop_word': True,
                     'skip_word': False,
                     'use': False,
                     'value': 'me'},
                 {
                     'start': 8,
                     'end': 16,
                     'pos': 'NN',
                     'stem': u'anyth',
                     'stop_word': False,
                     'skip_word': True,
                     'use': False,
                     'value': 'anything'
                 }
             ]
         }
     )