mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-24 00:46:28 +03:00
Allow step=1 when slicing a Doc
This commit is contained in:
parent
73566899bf
commit
2fc33e8024
|
@ -87,7 +87,7 @@ cdef class Doc:
|
|||
token (Token):
|
||||
"""
|
||||
if isinstance(i, slice):
|
||||
if i.step is not None:
|
||||
if not (i.step is None or i.step == 1):
|
||||
raise ValueError("Stepped slices not supported in Span objects."
|
||||
"Try: list(doc)[start:stop:step] instead.")
|
||||
if i.start is None:
|
||||
|
|
|
@ -16,6 +16,8 @@ def test_getitem(EN):
|
|||
assert not '/'.join(token.orth_ for token in span)
|
||||
span = tokens[1:4]
|
||||
assert '/'.join(token.orth_ for token in span) == 'it/back/!'
|
||||
span = tokens[1:4:1]
|
||||
assert '/'.join(token.orth_ for token in span) == 'it/back/!'
|
||||
with pytest.raises(ValueError):
|
||||
tokens[1:4:2]
|
||||
with pytest.raises(ValueError):
|
||||
|
|
Loading…
Reference in New Issue
Block a user