Skip to content

Commit 18e7911

Browse files
committed
Update documentation and var changes in RegexSplitter
PiperOrigin-RevId: 347910895
1 parent ad230eb commit 18e7911

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

tensorflow_text/python/ops/regex_split_ops.py

+11-12
Original file line numberDiff line numberDiff line change
@@ -210,26 +210,25 @@ def regex_split(input,
210210

211211

212212
class RegexSplitter(splitter.SplitterWithOffsets):
213-
"""A `Splitter` that splits sentences separated by a newline.
213+
"""`RegexSplitter` splits text on the given regular expression.
214214
215-
`RegexSplitter` splits text when a newline character is detected.
216-
The newline character is determined by a regex pattern. It also returns the
217-
sentence beginning and ending byte offsets as well.
215+
The default is a newline character pattern. It can also returns the beginning
216+
and ending byte offsets as well.
218217
"""
219218

220-
def __init__(self, new_sentence_regex=None):
219+
def __init__(self, split_regex=None):
221220
r"""Creates an instance of `RegexSplitter`.
222221
223222
Args:
224-
new_sentence_regex: (optional) A string containing the regex pattern of a
225-
new line sentence delimiter. Default is '\r?\n'.
223+
split_regex: (optional) A string containing the regex pattern of a
224+
delimiter to split on. Default is '\r?\n'.
226225
"""
227-
if not new_sentence_regex:
228-
new_sentence_regex = "\r?\n"
229-
self._new_sentence_regex = new_sentence_regex
226+
if not split_regex:
227+
split_regex = "\r?\n"
228+
self._split_regex = split_regex
230229

231230
def split(self, input): # pylint: disable=redefined-builtin
232-
return regex_split(input, self._new_sentence_regex)
231+
return regex_split(input, self._split_regex)
233232

234233
def split_with_offsets(self, input): # pylint: disable=redefined-builtin
235-
return regex_split_with_offsets(input, self._new_sentence_regex)
234+
return regex_split_with_offsets(input, self._split_regex)

0 commit comments

Comments
 (0)