Ejemplo n.º 1
0
class AlphaNumericFeatureExtractorTests(unittest.TestCase):
    def setUp(self):
        self.extractor = NEFeatureExtractor()

    def test_get_features(self):
        obj = {
            'target': ['a', 'boy', 'hits', '3', 'dogs', 'a11i', 'o8', 'www1'],
            'source':
            ['un', 'garcon', 'bate', '3', 'ou', '4', 'chiens', 'b2b'],
            'token': ['3', 'dogs', 'Tinky', 'and', 'Winky'],
            'index': (3, 8),
            'source_token': ['3', 'ou', 'Tinky', 'et', 'Winky'],
            'source_index': (3, 8)
        }

        (src_ne, tg_ne) = self.extractor.get_features(obj)
        self.assertEqual(src_ne, 1)
        self.assertEqual(tg_ne, 1)

    def test_get_features_no_src(self):
        obj_no_src = {
            'target': ['a', 'boy', 'hits', '3', 'dogs', 'a11i', 'o8', 'www1'],
            'source':
            ['un', 'garcon', 'bate', '3', 'ou', '4', 'chiens', 'b2b'],
            'token': ['3', 'dogs', 'Tinky', 'and', 'Winky'],
            'index': (3, 8),
            'source_token': [],
            'source_index': []
        }

        (src_ne, tg_ne) = self.extractor.get_features(obj_no_src)
        self.assertEqual(src_ne, 0)
        self.assertEqual(tg_ne, 1)

    def test_get_features_no_NE(self):
        obj_no_src = {
            'target': ['a', 'boy', 'hits', '3', 'dogs', 'a11i', 'o8', 'www1'],
            'source':
            ['un', 'garcon', 'bate', '3', 'ou', '4', 'chiens', 'b2b'],
            'token': ['3', 'dogs', 'aDa', 'and', 'ooO'],
            'index': (3, 8),
            'source_token': [],
            'source_index': []
        }

        (src_ne, tg_ne) = self.extractor.get_features(obj_no_src)
        self.assertEqual(src_ne, 0)
        self.assertEqual(tg_ne, 0)
Ejemplo n.º 2
0
class AlphaNumericFeatureExtractorTests(unittest.TestCase):

    def setUp(self):
        self.extractor = NEFeatureExtractor()

    def test_get_features(self):
        obj = {'target': ['a', 'boy', 'hits', '3', 'dogs', 'a11i', 'o8', 'www1'],
               'source': ['un', 'garcon', 'bate', '3', 'ou', '4', 'chiens', 'b2b'],
               'token': ['3', 'dogs', 'Tinky', 'and', 'Winky'],
               'index': (3, 8),
               'source_token': ['3', 'ou', 'Tinky', 'et', 'Winky'],
               'source_index': (3, 8)}

        (src_ne, tg_ne) = self.extractor.get_features(obj)
        self.assertEqual(src_ne, 1)
        self.assertEqual(tg_ne, 1)

    def test_get_features_no_src(self):
        obj_no_src = {'target': ['a', 'boy', 'hits', '3', 'dogs', 'a11i', 'o8', 'www1'],
               'source': ['un', 'garcon', 'bate', '3', 'ou', '4', 'chiens', 'b2b'],
               'token': ['3', 'dogs', 'Tinky', 'and', 'Winky'],
               'index': (3, 8),
               'source_token': [],
               'source_index': []}

        (src_ne, tg_ne) = self.extractor.get_features(obj_no_src)
        self.assertEqual(src_ne, 0)
        self.assertEqual(tg_ne, 1)

    def test_get_features_no_NE(self):
        obj_no_src = {'target': ['a', 'boy', 'hits', '3', 'dogs', 'a11i', 'o8', 'www1'],
               'source': ['un', 'garcon', 'bate', '3', 'ou', '4', 'chiens', 'b2b'],
               'token': ['3', 'dogs', 'aDa', 'and', 'ooO'],
               'index': (3, 8),
               'source_token': [],
               'source_index': []}

        (src_ne, tg_ne) = self.extractor.get_features(obj_no_src)
        self.assertEqual(src_ne, 0)
        self.assertEqual(tg_ne, 0)
Ejemplo n.º 3
0
 def setUp(self):
     self.extractor = NEFeatureExtractor()
Ejemplo n.º 4
0
 def setUp(self):
     self.extractor = NEFeatureExtractor()