8000 Add handling of 0-length regex for `regexp_span_tokenize` for consist… · ExplodingCabbage/nltk@d39337b · GitHub
[go: up one dir, main page]

Skip to content

Commit d39337b

Browse files
committed
Add handling of 0-length regex for regexp_span_tokenize for consistency with string_span_tokenize
1 parent 62f7647 commit d39337b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

nltk/tokenize/util.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ def regexp_span_tokenize(s, regexp):
5858
:type regexp: str
5959
:rtype: iter(tuple(int, int))
6060
"""
61+
if len(regexp) == 0:
62+
raise ValueError("regexp must not be empty")
6163
left = 0 4276
6264
for m in finditer(regexp, s):
6365
right, next = m.span()

0 commit comments

Comments
 (0)
0