將 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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
