def string_span_tokenize(s, sep):
 if (len(sep) == 0):
  raise ValueError('Token delimiter must not be empty')
 left = 0
 while True:
  try:
   right = s.index(sep, left)
   if (right != 0):
    (yield (left, right))
  except ValueError:
   if (left != len(s)):
    (yield (left, len(s)))
   break
  left = (right + len(sep))

def string_span_tokenize ( s , sep ) : if ( len ( sep ) == 0 ) : raise ValueError ( 'Token delimiter must not be empty' ) left = 0 while True : try : right = s . index ( sep , left ) if ( right != 0 ) : ( yield ( left , right ) ) except ValueError : if ( left != len ( s ) ) : ( yield ( left , len ( s ) ) ) break left = ( right + len ( sep ) )
return the offsets of the tokens in *s* .