def test_excluded_offsets(self): t = Terms(None) t.scoped_terms['_'] = [ Ref('term', 'lablab', (4, 6)), Ref('other', 'lablab', (8, 9)), Ref('more', 'nonnon', (1, 8)) ] self.assertEqual([(4, 6), (8, 9)], t.excluded_offsets('lablab', 'Some text')) self.assertEqual([(1, 8)], t.excluded_offsets('nonnon', 'Other')) self.assertEqual([], t.excluded_offsets('ababab', 'Ab ab ab'))
def test_excluded_offsets(self): t = Terms(None) t.scoped_terms['_'] = [ Ref('term', 'lablab', (4, 6)), Ref('other', 'lablab', (8, 9)), Ref('more', 'nonnon', (1, 8)) ] self.assertEqual([(4, 6), (8, 9)], t.excluded_offsets('lablab', 'Some text')) self.assertEqual([(1, 8)], t.excluded_offsets('nonnon', 'Other')) self.assertEqual([], t.excluded_offsets('ababab', 'Ab ab ab'))
def test_excluded_offsets_blacklist_word_boundaries(self): """If an exclusion begins/ends with word characters, the searching regex should make sure to only match on word boundaries""" settings.IGNORE_DEFINITIONS_IN['ALL'] = ['shed act', '(phrase)'] t = Terms(None) t.scoped_terms['_'] = [Ref('act', '28-6-d', 0)] excluded = t.excluded_offsets( Node("That's a watershed act", label=['28', '9'])) self.assertEqual([], excluded) excluded = t.excluded_offsets( Node("This has a '(phrase)' in it", label=['28', '9'])) self.assertNotEqual([], excluded)
def test_excluded_offsets_blacklist_word_boundaries(self): """If an exclusion begins/ends with word characters, the searching regex should make sure to only match on word boundaries""" settings.IGNORE_DEFINITIONS_IN['ALL'] = ['shed act', '(phrase)'] t = Terms(None) t.scoped_terms['_'] = [Ref('act', '28-6-d', 0)] excluded = t.excluded_offsets(Node("That's a watershed act", label=['28', '9'])) self.assertEqual([], excluded) excluded = t.excluded_offsets(Node("This has a '(phrase)' in it", label=['28', '9'])) self.assertNotEqual([], excluded)
def test_excluded_offsets(self): t = Terms(None) t.scoped_terms['_'] = [ Ref('term', 'lablab', 4), Ref('other', 'lablab', 8), Ref('more', 'nonnon', 1) ] self.assertEqual([(4, 8), (8, 13)], t.excluded_offsets(Node('Some text', label=['lablab']))) self.assertEqual([(1, 5)], t.excluded_offsets(Node('Other', label=['nonnon']))) self.assertEqual([], t.excluded_offsets(Node('Ab ab ab', label=['ababab'])))
def test_excluded_offsets(self): t = Terms(None) t.scoped_terms['_'] = [ Ref('term', 'lablab', 4), Ref('other', 'lablab', 8), Ref('more', 'nonnon', 1) ] self.assertEqual( [(4, 8), (8, 13)], t.excluded_offsets(Node('Some text', label=['lablab']))) self.assertEqual( [(1, 5)], t.excluded_offsets(Node('Other', label=['nonnon']))) self.assertEqual( [], t.excluded_offsets(Node('Ab ab ab', label=['ababab'])))
def test_excluded_offsets_blacklist(self): t = Terms(None) t.scoped_terms['_'] = [Ref('bourgeois', '12-Q-2', 0)] settings.IGNORE_DEFINITIONS_IN['ALL'] = ['bourgeois pig'] excluded = t.excluded_offsets( Node('You are a bourgeois pig!', label=['12', '3'])) self.assertEqual([(10, 23)], excluded)
def test_excluded_offsets_blacklist(self): t = Terms(None) t.scoped_terms['_'] = [Ref('bourgeois', '12-Q-2', 0)] settings.IGNORE_DEFINITIONS_IN['ALL'] = ['bourgeois pig'] excluded = t.excluded_offsets(Node('You are a bourgeois pig!', label=['12', '3'])) self.assertEqual([(10, 23)], excluded)
def test_excluded_offsets_blacklist_per_reg(self): t = Terms(None) t.scoped_terms['_'] = [ Ref('bourgeois', '12-Q-2', 0), Ref('consumer', '12-Q-3', 0)] settings.IGNORE_DEFINITIONS_IN['ALL'] = ['bourgeois pig'] settings.IGNORE_DEFINITIONS_IN['12'] = ['consumer price index'] excluded = t.excluded_offsets( Node('There is a consumer price index', label=['12', '2'])) self.assertEqual([(11, 31)], excluded)
def test_excluded_offsets_blacklist_per_reg(self): t = Terms(None) t.scoped_terms['_'] = [ Ref('bourgeois', '12-Q-2', 0), Ref('consumer', '12-Q-3', 0)] settings.IGNORE_DEFINITIONS_IN['ALL'] = ['bourgeois pig'] settings.IGNORE_DEFINITIONS_IN['12'] = ['consumer price index'] excluded = t.excluded_offsets( Node('There is a consumer price index', label=['12', '2'])) self.assertEqual([(11, 31)], excluded)
def test_excluded_offsets_blacklist_word_boundaries(self): t = Terms(None) t.scoped_terms['_'] = [Ref('act', '28-6-d', 'Def def def')] settings.IGNORE_DEFINITIONS_IN['ALL'] = ['shed act'] excluded = t.excluded_offsets('28-9', "That's a watershed act") self.assertEqual([], excluded)
def test_excluded_offsets_blacklist_word_boundaries(self): t = Terms(None) t.scoped_terms['_'] = [Ref('act', '28-6-d', 'Def def def')] settings.IGNORE_DEFINITIONS_IN['ALL'] = ['shed act'] excluded = t.excluded_offsets('28-9', "That's a watershed act") self.assertEqual([], excluded)
def test_excluded_offsets_blacklist(self): t = Terms(None) t.scoped_terms['_'] = [Ref('bourgeois', '12-Q-2', 'Def')] settings.IGNORE_DEFINITIONS_IN = ['bourgeois pig'] excluded = t.excluded_offsets('12-3', 'You are a bourgeois pig!') self.assertEqual([(10,23)], excluded)