fix(modules): treat DocumentSplitter separator as a literal string by ManoharPaturi · Pull Request #2376 · NVIDIA-NeMo/Curator · GitHub
Skip to content

fix(modules): treat DocumentSplitter separator as a literal string - #2376

Merged
sarahyurick merged 7 commits into
NVIDIA-NeMo:mainfrom
ManoharPaturi:fix/document-splitter-literal-separator
Sep 23, 2026
Merged

sarahyurick merged 7 commits into
NVIDIA-NeMo:mainfrom
ManoharPaturi:fix/document-splitter-literal-separator

Conversation

@ManoharPaturi

Copy link
Copy Markdown
Contributor

Fixes #2374.

One line: pass regex=False to the str.split call so the separator is treated as a literal string, matching the docstring and the DocumentJoiner round-trip (which always joins literally).

  • "..", "||", "(sep)" now split on the actual separator
  • "++" no longer raises re.error
  • round-trip split→join now reproduces the original text for metacharacter separators

3 new tests (metacharacter split, ++ crash, DocumentJoiner round-trip) — all fail on main, pass here. Rest of the splitter suite unchanged.

pandas Series.str.split interprets multi-character patterns as regular
expressions by default, so separators like "..", "||" or "(sep)" split
documents on the wrong boundaries, and invalid regexes like "++" crash
the stage with re.error. DocumentSplitter documents a plain separator
and DocumentJoiner joins with the literal separator, so the round-trip
between the two stages was also broken for such separators.

Pass regex=False so the separator always matches literally.

Signed-off-by: Manohar Paturi <186662190+ManoharPaturi@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 7, 2026 07:04
@ManoharPaturi
ManoharPaturi requested a review from a team as a code owner September 7, 2026 07:04
@ManoharPaturi
ManoharPaturi requested review from abhinavg4 and removed request for a team September 7, 2026 07:04
@copy-pr-bot

copy-pr-bot Bot commented Sep 7, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@greptile-apps

greptile-apps Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge with no outstanding correctness, compatibility, or security issues identified.

Summary

This PR makes DocumentSplitter interpret separators as literal strings rather than regular expressions.

  • Passes regex=False to pandas.Series.str.split.
  • Adds coverage for regex metacharacters, previously invalid patterns, segment ordering, and split/join round trips.

Reviews (7) · Last reviewed commit: "Merge branch 'main' into fix/document-sp..."

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the waiting-on-maintainers Waiting on maintainers to respond label Sep 9, 2026
reconstructed_doc2 = "\n\n".join(doc2_segments["text"].tolist())
assert reconstructed_doc2 == "Foo\n\nBar"

def test_separator_is_treated_as_literal_string(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ManoharPaturi thanks for opening! I was wondering is there any way for you to create a single parametrized test instead of adding 3 separate tests?

@ManoharPaturi ManoharPaturi Sep 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sarahyurick! That makes total sense I've consolidated the cases into a single @pytest.mark.parametrize test (test_literal_separator_and_joiner_roundtrip) covering multi-character metacharacters (..), invalid regexes (++), and groups ((sep)) along with the DocumentJoiner round trip. Formatted with Ruff and pushed in 0c2ceb4.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added waiting-on-customer Waiting on the original author to respond and removed waiting-on-maintainers Waiting on maintainers to respond labels Sep 18, 2026
Signed-off-by: Manohar Paturi <186662190+ManoharPaturi@users.noreply.github.com>
@svcnvidia-nemo-ci svcnvidia-nemo-ci added waiting-on-maintainers Waiting on maintainers to respond and removed waiting-on-customer Waiting on the original author to respond labels Sep 18, 2026
@sarahyurick

Copy link
Copy Markdown
Contributor

/ok to test c1ba87d

@sarahyurick

Copy link
Copy Markdown
Contributor

/ok to test 844e6f4

@sarahyurick

Copy link
Copy Markdown
Contributor

/ok to test a28ffab

@sarahyurick

Copy link
Copy Markdown
Contributor

This branch was successfully deployed

3 active deployments
nemo-ci — 0c4ead74 Deployed Sep 23, 2026 by copy-pr-bot[bot] via L0_Unit_Test_GPU-text #5622
public — 0c4ead74 Deployed Sep 23, 2026 by copy-pr-bot[bot] via release / finalize / notify #1163
test — 0c4ead74 Deployed Sep 23, 2026 by copy-pr-bot[bot] via cicd-wait-in-queue #5622
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DocumentSplitter treats multi-character separators as regex (wrong splits, re.error crash on "++")

4 participants