mindspore.dataset.text.CaseFold

class mindspore.dataset.text.CaseFold[源代码]

将UTF-8编码字符串中的字符规范化为小写,相比 str.lower 支持更多字符。

支持的输入规范化形式详见 ICU_Normalizer2

说明

Windows平台尚不支持 CaseFold

支持平台:

CPU

样例:

>>> import mindspore.dataset as ds
>>> import mindspore.dataset.text as text
>>>
>>> # Use the transform in dataset pipeline mode
>>> numpy_slices_dataset = ds.NumpySlicesDataset(data=['Welcome     To   BeiJing!'], column_names=["text"])
>>> case_op = text.CaseFold()
>>> numpy_slices_dataset = numpy_slices_dataset.map(operations=case_op)
>>> for item in numpy_slices_dataset.create_dict_iterator(num_epochs=1, output_numpy=True):
...     print(item["text"])
welcome     to   beijing!
>>>
>>> # Use the transform in eager mode
>>> data = 'Welcome     To   BeiJing!'
>>> output = text.CaseFold()(data)
>>> print(output)
welcome     to   beijing!
教程样例: