def test_match_has_correct_positions_basic(self): idx = index.get_index() querys = u'''Licensed under the GNU General Public License (GPL). Licensed under the GNU General Public License (GPL). Licensed under the GNU General Public License (GPL).''' matches = idx.match(query=querys, min_score=0) rule = [r for r in idx.rules_by_rid if r.identifier() == 'gpl-2.0_49.RULE'][0] m1 = LicenseMatch(rule=rule, _type='chunk1', qspans=[Span(0, 7)], ispans=[Span(0, 7)]) m1.lines = Span(1, 1) m2 = LicenseMatch(rule=rule, _type='chunk2', qspans=[Span(8, 15)], ispans=[Span(0, 7)]) m2.lines = Span(2, 2) m3 = LicenseMatch(rule=rule, _type='chunk3', qspans=[Span(16, 23)], ispans=[Span(0, 7)]) m3.lines = Span(3, 3) assert [m1, m2, m3] == matches
def test_match_works_for_apache_rule(self): idx = index.get_index() querys = u'''I am not a license. The Apache Software License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0.txt ''' matches = idx.match(query=querys, min_score=100) rule = [r for r in idx.rules_by_rid if r.identifier() == 'apache-2.0_8.RULE'][0] m1 = LicenseMatch(rule=rule, _type='chunk1', qspans=[Span(5, 20)], ispans=[Span(0, 15)]) m1.lines = Span(2, 3) assert [m1] == matches