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')), ], ])
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')), ], ])
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')])
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']), ], }, })
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']), ], }, })
def test_danske(self): self.index = IndexFinder(*load_index('tests/fixtures/index')) self.assertIndex('bank', 'danske bank', [(1, 'Danske', 'bank', 'pattern')])