Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Feature request: Modify `text.regex_split_with_offsets()` behavior to be in line with `tf.strings.length()`

Open
#1,245 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp, tensorflow

Research direction

Start with the text.regex_split_with_offsets() API and compare its documented offsets with tf.strings.length() and tf.strings.substr(), especially their BYTE and UTF8_CHAR behavior. Trace the implementation and existing tests for the split operation; done means the offsets use the requested unit and return tf.int32 values consistently with the related TensorFlow string APIs.

Written by the indexing model from the issue text.

Description

text.regex_split_with_offsets() currently returns begin and end as tf.int64 tensors that count indices in bytes.

tf.strings.length() on the other hand, returns a tf.int32 tensor which counts lengths in either bytes or UTF8 characters according to the value of the parameter unit.

So this would actually be two separate requests:

  1. Change the return types of text.regex_split_with_offsets() to tf.int32, removing the need for a cast when comparing with tf.strings.length(). I doubt there will be a use case for strings longer than INT32_MAX in the foreseeable future.
  2. Add parameter unit: Literal["BYTE", "UTF8_CHAR"] = "BYTE" matching the behavior of tf.strings.length() and tf.strings.substr(). Seeing the regular expressions are already being interpreted in 'utf-8', I think it would make sense to add a layer of abstraction to facilitate slicing by UTF-8 character index.
Dominant language
C++
Stars
1.3k
Forks
378
Avg merge
10h 48m
Merged PRs (30d)
2

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tensorflow/text

All issues in tensorflow/text

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.