nltk.slice_bounds()
¶
-
nltk.
slice_bounds
(sequence, slice_obj, allow_step=False)¶ Given a slice, return the corresponding (start, stop) bounds, taking into account None indices and negative indices. The following guarantees are made for the returned start and stop values:
- 0 <= start <= len(sequence)
- 0 <= stop <= len(sequence)
- start <= stop
Raises: ValueError – If slice_obj.step
is not None.Parameters: allow_step – If true, then the slice object may have a non-None step. If it does, then return a tuple (start, stop, step).