def test_drop_end_es(self): end_key = 'end_es' keep, drop = DictionaryForText._drop_ends( {'drive': 2, 'drives': 3, 'class': 4, 'classes': 5}, end_key ) self.assertEqual({'drive': 2, 'drives': 3, 'class': 9}, keep) self.assertEqual({'classes': 'class'}, drop[end_key])
def test_drop_end_ies(self): end_key = 'end_ies' keep, drop = DictionaryForText._drop_ends( {'entity': 2, 'entities': 3, 'class': 4}, end_key ) self.assertEqual({'entity': 5, 'class': 4}, keep) self.assertEqual({'entities': 'entity'}, drop[end_key])
def test_drop_end_apostrophe_s(self): end_key = 'end_apostrophe_s' keep, drop = DictionaryForText._drop_ends( {'item\'s': 2, 'item': 3, 'class': 4, 'item’s': 5}, end_key ) self.assertEqual({'item': 10, 'class': 4}, keep) self.assertEqual({'item\'s': 'item', 'item’s': 'item'}, drop[end_key])
def test_drop_end_s(self): end_key = 'end_s' keep, drop = DictionaryForText._drop_ends( {'items': 2, 'item': 3, 'class': 4, 'drive': 5, 'drives': 6}, end_key ) self.assertEqual({'item': 5, 'class': 4, 'drive': 11}, keep) self.assertEqual({'items': 'item', 'drives': 'drive'}, drop[end_key])
def test_exceptions(self): keep, drop = DictionaryForText._drop_ends( { 'seed': 2, 'see': 3, 'seeds': 1, 'spe': 4, 'speed': 5, 'bee': 2, 'bees': 3, 'be': 4, 'goods': 2, 'good': 3, 'http': 2, 'https': 3 }, ('end_ed', 'end_s', 'end_es') ) self.assertEqual( { 'seed': 3, 'see': 3, 'spe': 4, 'speed': 5, 'bee': 5, 'be': 4, 'goods': 2, 'good': 3, 'http': 2, 'https': 3 }, keep ) self.assertEqual({'seeds': 'seed', 'bees': 'bee'}, drop['end_s']) self.assertEqual({}, drop['end_ed'])
def test_drop_end_ing(self): end_key = 'end_ing' keep, drop = DictionaryForText._drop_ends( { 'make': 1, 'making': 1, 'running': 2, 'run': 2, 'craft': 4, 'crafting': 4, 'string': 5 }, end_key ) self.assertEqual({'make': 2, 'run': 4, 'craft': 8, 'string': 5}, keep) self.assertEqual( { 'making': 'make', 'running': 'run', 'crafting': 'craft' }, drop[end_key] )
def test_drop_end_ed(self): end_key = 'end_ed' keep, drop = DictionaryForText._drop_ends( { 'called': 2, 'call': 3, 'word': 1, 'create': 4, 'created': 5, 'drop': 1, 'dropped': 1 }, end_key ) self.assertEqual({'call': 5, 'word': 1, 'create': 9, 'drop': 2}, keep) self.assertEqual( { 'called': 'call', 'created': 'create', 'dropped': 'drop' }, drop[end_key] )