Skip to content

fix(text-analyzer): leave punctuation-only tokens out of the top words - #738

Merged
rng1995 merged 5 commits into
NVIDIA:mainfrom
dhananjay6561:fix/text-analyzer-punctuation-top-words
Nov 17, 2026
Merged

rng1995 merged 5 commits into
NVIDIA:mainfrom
dhananjay6561:fix/text-analyzer-punctuation-top-words

Conversation

@dhananjay6561

Copy link
Copy Markdown
Contributor

Summary

The text-analyzer reference skill built its "Top words" from text.split() tokens with a fixed set of punctuation stripped, so tokens that are only punctuation ended up in the list. An ellipsis ... stripped to the empty string and was reported as the word "", and dashes (-, –, —) or & were reported as words. In text with a few of those they took places in the top 5 and pushed real words out, and the text report printed a blank row.

Top words now only count tokens that contain at least one letter or digit. For Wait... what? ... ok ... - fine - yes! the top words go from "", "-", wait, what, ok to wait, what, ok, fine, yes. Word, line, character and sentence counts are unchanged, as are tokens like v2, don't, 3.14 and well-known, and the starter eval text still reports 20 words, 97 characters, 3 sentences and the ×5.

Fixes #736.

Verification

  • I am familiar with the Contributing Guidelines
  • Added or updated focused tests
  • Updated documentation for user-visible changes
  • Ran make lint
  • Ran make test
  • Ran make build
  • Did not add credentials, private datasets, or proprietary benchmark content

Tested on macOS 26.6 arm64, Python 3.14.7, on top of upstream d2cb1388.

  • pytest -n 0 tests/test_reference_text_analyzer.py: 3 passed. Against the unchanged analyze_text.py the punctuation test fails and the other two pass.
  • ruff check src tests and ruff format --check on the changed files: passed.
  • python -m build: built the sdist and wheel.
  • I didn't run the full make test suite; the change is limited to the standalone text-analyzer script, which nothing else imports.

Release Impact

  • No user-visible release note needed
  • Updated CHANGELOG.md

Signed-off-by: dhananjay6561 <dhananjayaggarwal6561@gmail.com>
Signed-off-by: dhananjay6561 <dhananjayaggarwal6561@gmail.com>
Signed-off-by: dhananjay6561 <dhananjayaggarwal6561@gmail.com>
Copilot AI balanced review requested due to automatic review settings November 17, 2026 04:03

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 insufficient remaining quota. Try requesting a review at a lower effort level.

@chrisknvidia chrisknvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, reproduced on main: --text 'Wait... what? ... ok ... - fine - yes!' listed "" and - as the two most frequent words and printed a blank row in the report. With this branch the top words are wait, what, ok, fine, yes, and the starter eval text (The quick brown fox...) produces byte-identical JSON before and after, so the dataset and the recorded expectations (20 words, 97 characters, 3 sentences, the x5) are unaffected.

I checked a few more tokens: v2, don't, 3.14, well-known, café, €5 and CJK text are all kept, while ©, _, & and en/em dashes are dropped, which matches the intent. The new test fails on the old script and passes with the fix, ruff is clean, all commits are signed off, and the changelog entry is under Unreleased / Fixed.

One not-blocking thought inline about word_count. Otherwise good to go.

@dhananjay6561

Copy link
Copy Markdown
Contributor Author

@chrisknvidia thanks for the thorough check! I replied to the word_count note inline. If you're happy keeping this PR scoped as is, it should be good to merge.

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for your contribution, @dhananjay6561. Reviewed e41cc1943d0d; no new actionable defects found. Filtering punctuation-only entries fixes top_words while retaining numbers, inner punctuation, and stable frequency ordering. The recorded starter statistics remain compatible.

Validation: All 3 reference text-analyzer tests passed.

I read the existing word_count/average_word_length discussion and the author's reply. Keeping those established metrics unchanged is reasonable for this top_words fix; I have no additional change request.

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, @dhananjay6561. Rechecked 61b5b98a508e and the latest discussion. The delta from e41cc1943d0d only merges main's task-list fix (#680), its tests and changelog. Text-analyzer source, its regression tests and dependencies are unchanged; no new actionable defects found.

Retained validation: all 3 text-analyzer tests passed on e41cc1943d0d; I did not rerun them for this unrelated merge. The existing word_count/average_word_length note and your reply still support keeping this fix scoped to top_words; I have no additional change request.

@rng1995
rng1995 merged commit c43365b into NVIDIA:main Nov 17, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Text-analyzer top words include punctuation-only tokens such as "" and "-"

4 participants