Esempio n. 1
0
 def test_new_bad_values(self):
     with raises(AssertionError):
         token(1, 'ns', (1, 2))
     with raises(AssertionError):
         token('txt', 1, (1, 2))
     with raises(TypeError):
         token('txt', 'ns', 1)
     with raises(ValueError):
         token('txt', 'ns', (1,))
     with raises(ValueError):
         token('txt', 'ns', (1, 2, 3))
Esempio n. 2
0
 def test_new_bad_values(self):
     with raises(AssertionError):
         token(1, 'ns', (1, 2))
     with raises(AssertionError):
         token('txt', 1, (1, 2))
     with raises(TypeError):
         token('txt', 'ns', 1)
     with raises(ValueError):
         token('txt', 'ns', (1, ))
     with raises(ValueError):
         token('txt', 'ns', (1, 2, 3))
Esempio n. 3
0
    def test_copy_bad_values(self):
        opts = (None, ) * 5

        with raises(AssertionError):
            token((1, 'ns', (1, 2)) + opts)
        with raises(AssertionError):
            token(('txt', 1, (1, 2)) + opts)
        with raises(TypeError):
            token(('txt', 'ns', 1) + opts)
        with raises(ValueError):
            token(('txt', 'ns', (1, )) + opts)
        with raises(ValueError):
            token(('txt', 'ns', (1, 2, 3)) + opts)
Esempio n. 4
0
    def test_copy_bad_values(self):
        opts = (None,) * 5

        with raises(AssertionError):
            token((1, 'ns', (1, 2)) + opts)
        with raises(AssertionError):
            token(('txt', 1, (1, 2)) + opts)
        with raises(TypeError):
            token(('txt', 'ns', 1) + opts)
        with raises(ValueError):
            token(('txt', 'ns', (1,)) + opts)
        with raises(ValueError):
            token(('txt', 'ns', (1, 2, 3)) + opts)
Esempio n. 5
0
 def test_ChunkIs_methods(self):
     t = token('txt', 'ns', (1, 2), chunk='B-chunk')
     assert t.ChunkIs('chunk')
     assert not t.ChunkIs('other')
     assert t.ChunkIsBegin()
     assert not t.ChunkIsInside()
     assert not t.ChunkIsOutside()
Esempio n. 6
0
 def test_EntityIs_methods(self):
     t = token('txt', 'ns', (1, 2), entity='I-entity')
     assert t.EntityIs('entity')
     assert not t.EntityIs('other')
     assert not t.EntityIsBegin()
     assert t.EntityIsInside()
     assert not t.EntityIsOutside()
Esempio n. 7
0
 def test_PosIs_methods(self):
     t = token('txt', 'ns', (1, 2), pos='NNS')
     assert t.PosIs('NNS')
     assert not t.PosIs('VBZ')
     assert not t.PosIs(None)
     assert t.PosStartswith('NN')
     assert not t.PosStartswith('VB')
Esempio n. 8
0
 def test_PosIs_methods(self):
     t = token('txt', 'ns', (1, 2), pos='NNS')
     assert t.PosIs('NNS')
     assert not t.PosIs('VBZ')
     assert not t.PosIs(None)
     assert t.PosStartswith('NN')
     assert not t.PosStartswith('VB')
Esempio n. 9
0
 def test_ChunkIs_methods(self):
     t = token('txt', 'ns', (1, 2), chunk='B-chunk')
     assert t.ChunkIs('chunk')
     assert not t.ChunkIs('other')
     assert t.ChunkIsBegin()
     assert not t.ChunkIsInside()
     assert not t.ChunkIsOutside()
Esempio n. 10
0
 def test_EntityIs_methods(self):
     t = token('txt', 'ns', (1, 2), entity='I-entity')
     assert t.EntityIs('entity')
     assert not t.EntityIs('other')
     assert not t.EntityIsBegin()
     assert t.EntityIsInside()
     assert not t.EntityIsOutside()
Esempio n. 11
0
 def test_new_ignore_unused_keywords(self):
     t = token('txt',
               'ns', (1, 2),
               norm='norm',
               entity='entity',
               funny='haha')
     CheckAttributes(t)
     CheckTags(t, norm='norm', entity='entity')
Esempio n. 12
0
 def test_Update(self):
     t1 = token('txt', 'ns', (1, 2), norm='norm', entity='entity')
     assert 'sentinel' == t1.pos.get_or('sentinel')
     t2 = t1.Update(pos='pos')
     assert 'pos' == t2.pos.get_or('sentinel')
     assert 'sentinel' == t1.pos.get_or('sentinel')
     t3 = t2.Update(text='another', namespace='different', offset=(2, 3))
     assert 'another' == t3.text
     assert 'different' == t3.namespace
     assert (2, 3) == t3.offset
Esempio n. 13
0
 def test_Update(self):
     t1 = token('txt', 'ns', (1, 2), norm='norm', entity='entity')
     assert 'sentinel' == t1.pos.get_or('sentinel')
     t2 = t1.Update(pos='pos')
     assert 'pos' == t2.pos.get_or('sentinel')
     assert 'sentinel' == t1.pos.get_or('sentinel')
     t3 = t2.Update(text='another', namespace='different', offset=(2, 3))
     assert 'another' == t3.text
     assert 'different' == t3.namespace
     assert (2, 3) == t3.offset
Esempio n. 14
0
 def test_new_missing_values(self):
     with raises(ValueError):
         token('txt', 'ns')
     with raises(ValueError):
         token('txt')
     with raises(ValueError):
         token('12345678')
Esempio n. 15
0
 def test_new_missing_values(self):
     with raises(ValueError):
         token('txt', 'ns')
     with raises(ValueError):
         token('txt')
     with raises(ValueError):
         token('12345678')
Esempio n. 16
0
    def test_Update_bad_values(self):
        t = token('txt', 'ns', (1, 2), norm='norm', entity='entity')

        with raises(AssertionError):
            t.Update(text=1)
        with raises(AssertionError):
            t.Update(namespace=1)
        with raises(TypeError):
            t.Update(offset=1)
        with raises(ValueError):
            t.Update(offset=(1, ))
        with raises(ValueError):
            t.Update(offset=(1, 2, 3))
Esempio n. 17
0
    def test_Update_bad_values(self):
        t = token('txt', 'ns', (1, 2), norm='norm', entity='entity')

        with raises(AssertionError):
            t.Update(text=1)
        with raises(AssertionError):
            t.Update(namespace=1)
        with raises(TypeError):
            t.Update(offset=1)
        with raises(ValueError):
            t.Update(offset=(1,))
        with raises(ValueError):
            t.Update(offset=(1, 2, 3))
Esempio n. 18
0
 def test_PosIs_None(self):
     t = token('txt', 'ns', (1, 2))
     assert t.PosIs(None)
     assert not t.PosIs('NNS')
     assert not t.PosStartswith('')
Esempio n. 19
0
 def test_PosIs_None(self):
     t = token('txt', 'ns', (1, 2))
     assert t.PosIs(None)
     assert not t.PosIs('NNS')
     assert not t.PosStartswith('')
Esempio n. 20
0
 def test_new_all_values(self):
     t = token('txt', 'ns', (1, 2), *TAGS)
     CheckAttributes(t)
     CheckTags(t, *TAGS)
Esempio n. 21
0
 def test_str_with_tabs(self):
     t = token('txt', 'n\ts', (1, 2), norm='st\t\tem', entity='en\tti\tty')
     assert "n\\ts\t1:2\tst\\t\\tem\t\\N\t\\N\t\\N\ten\\tti\\tty" == str(t)
Esempio n. 22
0
 def test_str(self):
     t = token('txt', 'ns', (1, 2), norm='norm', entity='entity')
     assert "ns\t1:2\tnorm\t\\N\t\\N\t\\N\tentity" == str(t)
Esempio n. 23
0
 def test_new_ignore_unused_keywords(self):
     t = token('txt', 'ns', (1, 2), norm='norm', entity='entity', funny='haha')
     CheckAttributes(t)
     CheckTags(t, norm='norm', entity='entity')
Esempio n. 24
0
 def test_copy_tuple(self):
     t = token(('txt', 'ns', (1, 2)) + TAGS)
     CheckAttributes(t)
     CheckTags(t, *TAGS)
Esempio n. 25
0
 def test_repr(self):
     t = token('txt', 'ns', (1, 2), norm='norm', entity='entity')
     assert "token(ns, 'x', norm='norm', entity='entity')" == repr(t)
Esempio n. 26
0
 def test_new_ignore_excess_values(self):
     tags = TAGS + ('junk',)
     t = token('txt', 'ns', (1, 2), *tags)
     CheckAttributes(t)
     CheckTags(t, *TAGS)
Esempio n. 27
0
 def test_new_ignore_excess_values(self):
     tags = TAGS + ('junk', )
     t = token('txt', 'ns', (1, 2), *tags)
     CheckAttributes(t)
     CheckTags(t, *TAGS)
Esempio n. 28
0
 def test_new_all_values(self):
     t = token('txt', 'ns', (1, 2), *TAGS)
     CheckAttributes(t)
     CheckTags(t, *TAGS)
Esempio n. 29
0
 def test_str(self):
     t = token('txt', 'ns', (1, 2), norm='norm', entity='entity')
     assert "ns\t1:2\tnorm\t\\N\t\\N\t\\N\tentity" == str(t)
Esempio n. 30
0
 def test_new_most_values(self):
     t = token('txt', 'ns', (1, 2), 'norm', 'ortho')
     CheckAttributes(t)
     CheckTags(t, norm='norm', ortho='ortho')
Esempio n. 31
0
 def test_copy(self):
     t = token(token('txt', 'ns', (1, 2)))
     assert isinstance(t, token)
     CheckAttributes(t)
     CheckTags(t)
Esempio n. 32
0
 def test_new_using_keywords(self):
     t = token('txt', 'ns', (1, 2), norm='norm', entity='entity')
     CheckAttributes(t)
     CheckTags(t, norm='norm', entity='entity')
Esempio n. 33
0
 def test_new_most_values(self):
     t = token('txt', 'ns', (1, 2), 'norm', 'ortho')
     CheckAttributes(t)
     CheckTags(t, norm='norm', ortho='ortho')
Esempio n. 34
0
 def test_copy_tuple(self):
     t = token(('txt', 'ns', (1, 2)) + TAGS)
     CheckAttributes(t)
     CheckTags(t, *TAGS)
Esempio n. 35
0
 def test_new_using_keywords(self):
     t = token('txt', 'ns', (1, 2), norm='norm', entity='entity')
     CheckAttributes(t)
     CheckTags(t, norm='norm', entity='entity')
Esempio n. 36
0
 def test_copy_too_short(self):
     with raises(ValueError):
         token(('txt', 'ns', (1, 2), 'norm', 'pos'))
Esempio n. 37
0
 def test_infered_properties(self):
     t = token('text', 'ns', (1, 3))
     assert 1 == t.begin
     assert 3 == t.end
     assert 'ex' == t.word
Esempio n. 38
0
 def test_infered_properties(self):
     t = token('text', 'ns', (1, 3))
     assert 1 == t.begin
     assert 3 == t.end
     assert 'ex' == t.word
Esempio n. 39
0
 def test_copy(self):
     t = token(token('txt', 'ns', (1, 2)))
     assert isinstance(t, token)
     CheckAttributes(t)
     CheckTags(t)
Esempio n. 40
0
 def test_repr(self):
     t = token('txt', 'ns', (1, 2), norm='norm', entity='entity')
     assert "token(ns, 'x', norm='norm', entity='entity')" == repr(t)
Esempio n. 41
0
 def test_copy_too_short(self):
     with raises(ValueError):
         token(('txt', 'ns', (1, 2), 'norm', 'pos'))
Esempio n. 42
0
 def test_str_with_tabs(self):
     t = token('txt', 'n\ts', (1, 2), norm='st\t\tem', entity='en\tti\tty')
     assert "n\\ts\t1:2\tst\\t\\tem\t\\N\t\\N\t\\N\ten\\tti\\tty" == str(t)