将 input 中的每个字符串拆分为一系列 Unicode 代码点。
用法
tf.strings.unicode_split(
input, input_encoding, errors='replace', replacement_char=65533,
name=None
)参数
-
input一个N维度可能参差不齐的string张量,形状为[D1...DN]。N必须是静态已知的。 -
input_encoding用于解码每个字符串的 unicode 编码的字符串名称。 -
errors指定无法使用指示的编码转换输入字符串时的响应。之一:'strict':为任何非法子字符串引发异常。'replace':用replacement_char替换非法子字符串。'ignore':跳过非法子串。
-
replacement_char当errors='replace'时用于代替input中的无效子字符串的替换代码点。 -
name操作的名称(可选)。
返回
-
一个
N+1维度int32张量,形状为[D1...DN, (num_chars)]。如果input是标量,则返回的张量为tf.Tensor,否则为tf.RaggedTensor。
result[i1...iN, j] 是 input[i1...iN] 的子字符串,当使用 input_encoding 解码时,它编码其第 j 个字符。
例子:
input = [s.encode('utf8') for s in (u'G\xf6\xf6dnight', u'\U0001f60a')]
tf.strings.unicode_split(input, 'UTF-8').to_list()
[[b'G', b'\xc3\xb6', b'\xc3\xb6', b'd', b'n', b'i', b'g', b'h', b't'],
[b'\xf0\x9f\x98\x8a']]
相关用法
- Python tf.strings.unicode_split_with_offsets用法及代码示例
- Python tf.strings.unicode_script用法及代码示例
- Python tf.strings.unicode_decode_with_offsets用法及代码示例
- Python tf.strings.unicode_decode用法及代码示例
- Python tf.strings.unicode_encode用法及代码示例
- Python tf.strings.unicode_transcode用法及代码示例
- Python tf.strings.unsorted_segment_join用法及代码示例
- Python tf.strings.upper用法及代码示例
- Python tf.strings.substr用法及代码示例
- Python tf.strings.reduce_join用法及代码示例
- Python tf.strings.regex_full_match用法及代码示例
- Python tf.strings.regex_replace用法及代码示例
- Python tf.strings.length用法及代码示例
- Python tf.strings.bytes_split用法及代码示例
- Python tf.strings.as_string用法及代码示例
- Python tf.strings.lower用法及代码示例
- Python tf.strings.split用法及代码示例
- Python tf.strings.join用法及代码示例
- Python tf.strings.to_hash_bucket用法及代码示例
- Python tf.strings.ngrams用法及代码示例
注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.strings.unicode_split。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
