diff options
author | A. Unique TensorFlower <gardener@tensorflow.org> | 2018-10-04 11:30:52 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-10-04 11:34:46 -0700 |
commit | 700c3325311e16be9bb4856cbf944d1871ff35c1 (patch) | |
tree | 9ae88328889950abaa951a628de7212caec8c026 /tensorflow/python/ops | |
parent | c8d5054e8c12800f0c3db0e51f3d5902e04eaa37 (diff) |
Add "encoding" attribute to string substr op, which controls how each "character" is treated:
* BYTE: Position & length refer to bytes in the string. (Default)
* UTF8: The string is interpreted as UTF-8 encoded Unicode code points, and position & length are treated relative to them.
RELNOTES: Add option to get substring using Unicode characters
PiperOrigin-RevId: 215773373
Diffstat (limited to 'tensorflow/python/ops')
-rw-r--r-- | tensorflow/python/ops/string_ops.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tensorflow/python/ops/string_ops.py b/tensorflow/python/ops/string_ops.py index 0812f901a2..f26388efea 100644 --- a/tensorflow/python/ops/string_ops.py +++ b/tensorflow/python/ops/string_ops.py @@ -347,6 +347,22 @@ def string_length(input, name=None, unit="BYTE"): string_length.__doc__ = gen_string_ops.string_length.__doc__ +@tf_export("substr") +@deprecation.deprecated(None, "Use `tf.strings.substr` instead of `tf.substr`.") +def substr_deprecated(input, pos, len, name=None, unit="BYTE"): + return substr(input, pos, len, name=name, unit=unit) + +substr_deprecated.__doc__ = gen_string_ops.substr.__doc__ + + +@tf_export("strings.substr") +def substr(input, pos, len, name=None, unit="BYTE"): + return gen_string_ops.substr(input, pos, len, unit=unit, name=name) + + +substr.__doc__ = gen_string_ops.substr.__doc__ + + ops.NotDifferentiable("RegexReplace") ops.NotDifferentiable("StringToHashBucket") ops.NotDifferentiable("StringToHashBucketFast") |