mindspore.dataset.text.transforms.PythonTokenizer

class mindspore.dataset.text.transforms.PythonTokenizer(tokenizer)[source]

Class that applies user-defined string tokenizer into input string.

Parameters

tokenizer (Callable) – Python function that takes a str and returns a list of str as tokens.

Raises

TypeError – If tokenizer is not a callable Python function.

Supported Platforms:

CPU

Examples

>>> def my_tokenizer(line):
...     return line.split()
>>> text_file_dataset = text_file_dataset.map(operations=text.PythonTokenizer(my_tokenizer))