tf.strings.split
Stay organized with collections
Save and categorize content based on your preferences.
Split elements of input based on sep into a RaggedTensor.
tf.strings.split(
input, sep=None, maxsplit=-1, name=None
)
Let N be the size of input (typically N will be the batch size). Split each
element of input based on sep and return a RaggedTensor containing the
split tokens. Empty tokens are ignored.
Example:
tf.strings.split('hello world').numpy()
array([b'hello', b'world'], dtype=object)
tf.strings.split(['hello world', 'a b c'])
<tf.RaggedTensor [[b'hello', b'world'], [b'a', b'b', b'c']]>
If sep is given, consecutive delimiters are not grouped together and are
deemed to delimit empty strings. For example, input of "1<>2<><>3" and
sep of "<>" returns ["1", "2", "", "3"]. If sep is None or an empty
string, consecutive whitespace are regarded as a single separator, and the
result will contain no empty strings at the start or end if the string has
leading or trailing whitespace.
Note that the above mentioned behavior matches python's str.split.
Args |
input
|
A string Tensor of rank N, the strings to split. If
rank(input) is not known statically, then it is assumed to be 1.
|
sep
|
0-D string Tensor, the delimiter string.
|
maxsplit
|
An int. If maxsplit > 0, limit of the split of the result.
|
name
|
A name for the operation (optional).
|
Raises |
ValueError
|
If sep is not a string.
|
Returns |
A RaggedTensor of rank N+1, the strings split according to the
delimiter.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2023-10-06 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-10-06 UTC."],[],[]]