def set_offset(self,off,whence=0):
"""Set the offset of the tokenization routine.
For more details on the purpose of the tokenization offset,
see the documentation of the 'enchant.tokenize' module.
The optional argument whence indicates the method by
which to change the offset:
* 0 (the default) treats <off> as an increment
* 1 treats <off> as a distance from the start
* 2 treats <off> as a distance from the end
"""
if whence == 0:
self._tokens.set_offset(self._tokens.offset + off)
elif whence == 1:
assert(off > 0)
self._tokens.set_offset(off)
elif whence == 2:
assert(off > 0)
self._tokens.set_offset(len(self._text) - 1 - off)
else:
raise ValueError("Invalid value for whence: %s"%(whence,))
评论列表
文章目录