コード例 #1
0
 def test_patterns(self):
     self.index = IndexFinder(*load_index('tests/fixtures/index'))
     pattern = [('company-type', ()), ('company', ())]
     value = 'uždaroji akcinė bendrovė programmers of vilnius'
     self.assertEqual(list(self.index.pattern_finder(pattern, value.split())), [
         [
             (('company-type', ()), (1, 'UAB', 'company-type', 'alias')),
             (('company', ()), (5, 'Programuotojų artelė', 'company', 'alias')),
         ],
     ])
コード例 #2
0
 def test_patterns(self):
     self.index = IndexFinder(*load_index('tests/fixtures/index'))
     pattern = [('company-type', ()), ('company', ())]
     value = 'uždaroji akcinė bendrovė programmers of vilnius'
     self.assertEqual(
         list(self.index.pattern_finder(pattern, value.split())), [
             [
                 (('company-type', ()),
                  (1, 'UAB', 'company-type', 'alias')),
                 (('company', ()),
                  (5, 'Programuotojų artelė', 'company', 'alias')),
             ],
         ])
コード例 #3
0
 def test_find(self):
     self.index = IndexFinder(*load_index('tests/fixtures/index'))
     self.assertIndex('bank', 'unknown', [])
     self.assertIndex('bank', 'unknown', [])
     self.assertIndex('bank', 'dnb', [(2, 'DNB', 'bank', 'index')])
     self.assertIndex('bank', 'seb', [(3, 'SEB', 'bank', 'index')])
     self.assertIndex('bank', 'danske bank', [(1, 'Danske', 'bank', 'pattern')])
     self.assertIndex('company', 'dnb bankas', [
         (2, 'DNB bankas', 'company', 'index'),
         (2, 'DNB bankas', 'company', 'pattern'),
     ])
     self.assertIndex('company', 'dnb', [(2, 'DNB bankas', 'company', 'pattern')])
     self.assertIndex('company', 'danske bank', [(1, 'Danske bankas', 'company', 'pattern')])
     self.assertIndex('company', 'bankas swedbank', [(4, 'Swedbank bankas', 'company', 'pattern')])
     self.assertIndex('company', 'dnb lizingas', [(2, 'DNB bankas', 'company', 'pattern')])
コード例 #4
0
 def test_load_index(self):
     self.maxDiff = None
     data, debug_info = load_index('tests/fixtures/index')
     self.assertEqual(
         data, {
             'bank': {
                 'index': [
                     (1, 'Danske'),
                     (2, 'DNB'),
                     (3, 'SEB'),
                     (4, 'Swedbank'),
                 ],
                 'aliases': [
                     ('{bank}', [
                         '{bank} bankas',
                         '{bank} bank',
                         'bankas {bank}',
                         '{bank:lemma} lizingas',
                     ]),
                 ],
             },
             'company-type': {
                 'index': [
                     (1, 'UAB'),
                     (2, 'IĮ'),
                 ],
                 'aliases': [
                     ('UAB', ['Uždaroji akcinė bendrovė']),
                     ('IĮ', ['Individuali įmonė']),
                 ],
             },
             'company': {
                 'index': [
                     (1, 'Danske bankas'),
                     (2, 'DNB bankas'),
                     (3, 'SEB bankas'),
                     (4, 'Swedbank bankas'),
                     (5, 'Programuotojų artelė'),
                 ],
                 'aliases': [
                     ('{bank} bankas', ['{bank}']),
                     ('{company}', ['{company-type} {company}']),
                     ('Programuotojų artelė', ['Programmers of Vilnius']),
                 ],
             },
         })
コード例 #5
0
 def test_load_index(self):
     self.maxDiff = None
     data, debug_info = load_index('tests/fixtures/index')
     self.assertEqual(data, {
         'bank': {
             'index': [
                 (1, 'Danske'),
                 (2, 'DNB'),
                 (3, 'SEB'),
                 (4, 'Swedbank'),
             ],
             'aliases': [
                 ('{bank}', [
                     '{bank} bankas',
                     '{bank} bank',
                     'bankas {bank}',
                     '{bank:lemma} lizingas',
                 ]),
             ],
         },
         'company-type': {
             'index': [
                 (1, 'UAB'),
                 (2, 'IĮ'),
             ],
             'aliases': [
                 ('UAB', ['Uždaroji akcinė bendrovė']),
                 ('IĮ', ['Individuali įmonė']),
             ],
         },
         'company': {
             'index': [
                 (1, 'Danske bankas'),
                 (2, 'DNB bankas'),
                 (3, 'SEB bankas'),
                 (4, 'Swedbank bankas'),
                 (5, 'Programuotojų artelė'),
             ],
             'aliases': [
                 ('{bank} bankas', ['{bank}']),
                 ('{company}', ['{company-type} {company}']),
                 ('Programuotojų artelė', ['Programmers of Vilnius']),
             ],
         },
     })
コード例 #6
0
 def test_find(self):
     self.index = IndexFinder(*load_index('tests/fixtures/index'))
     self.assertIndex('bank', 'unknown', [])
     self.assertIndex('bank', 'unknown', [])
     self.assertIndex('bank', 'dnb', [(2, 'DNB', 'bank', 'index')])
     self.assertIndex('bank', 'seb', [(3, 'SEB', 'bank', 'index')])
     self.assertIndex('bank', 'danske bank',
                      [(1, 'Danske', 'bank', 'pattern')])
     self.assertIndex('company', 'dnb bankas', [
         (2, 'DNB bankas', 'company', 'index'),
         (2, 'DNB bankas', 'company', 'pattern'),
     ])
     self.assertIndex('company', 'dnb',
                      [(2, 'DNB bankas', 'company', 'pattern')])
     self.assertIndex('company', 'danske bank',
                      [(1, 'Danske bankas', 'company', 'pattern')])
     self.assertIndex('company', 'bankas swedbank',
                      [(4, 'Swedbank bankas', 'company', 'pattern')])
     self.assertIndex('company', 'dnb lizingas',
                      [(2, 'DNB bankas', 'company', 'pattern')])
コード例 #7
0
 def test_danske(self):
     self.index = IndexFinder(*load_index('tests/fixtures/index'))
     self.assertIndex('bank', 'danske bank',
                      [(1, 'Danske', 'bank', 'pattern')])
コード例 #8
0
 def test_danske(self):
     self.index = IndexFinder(*load_index('tests/fixtures/index'))
     self.assertIndex('bank', 'danske bank', [(1, 'Danske', 'bank', 'pattern')])