(text, func)
| 293 | |
| 294 | |
| 295 | def chunk_text(text, func): # type (str, Callable[[str], bool]) -> Iterable[str] |
| 296 | acc = '' |
| 297 | for x in text: |
| 298 | if func(x): |
| 299 | acc += x |
| 300 | else: |
| 301 | if acc: |
| 302 | yield acc |
| 303 | acc = '' |
| 304 | if acc: |
| 305 | yield acc |
| 306 | |
| 307 | |
| 308 | def offset_char(text, func): # type (str, Callable[[str, str], int]) -> Iterable[int] |