Skip to content

fix(cli): count a contraction as one word in line_unread - #6346

Queued
bercedev wants to merge 1 commit into
heygen-com:mainfrom
bercedev:fix/reading-words-contractions
Queued

bercedev wants to merge 1 commit into
heygen-com:mainfrom
bercedev:fix/reading-words-contractions

Conversation

@bercedev

Copy link
Copy Markdown

What

readingWords() keeps an apostrophe between letters inside a word run, so can't, can’t, don't and it's count as one word each.

Why

WORD_RUNS stopped at ' and ’, so every contraction counted as two words and line_unread set a longer hold floor than the line's real word count. "a tooth can't get in" counted 6 words instead of 5.

Related work

Refs #6338. This covers the contractions. Hyphenated words still count per part: Intl.Segmenter splits rock-and-roll at the hyphens even inside one run, and for a hold time three parts read about as long as three words, so I left that as is. The docs pointer about the captions track from the same issue isn't in here either.

How

The run regex now takes ['’] followed by more letters or numbers: /[\p{L}\p{M}\p{N}%$]+(?:['’][\p{L}\p{M}\p{N}]+)*/gu. A quote that doesn't sit between letters ('quoted', a lone ') still isn't part of a run. The segmenter keeps can't as one word-like segment, so the CJK path is unchanged.

Test plan

  • Unit tests added/updated: new case in craftAudit.test.ts (straight and typographic apostrophe, plus a quoted word). It fails on main (expected 6 to be 5) and passes here; the file's 21 tests pass.
  • Manual testing performed
  • Documentation updated (if applicable)
  • Comments follow CONTRIBUTING.md "Comments": they say why, not what, and a bug fix says what the code must do and how to reproduce the bug

oxlint and oxfmt --check are clean on both files.

WORD_RUNS split at apostrophes, so "can't" counted as two words and a line with contractions got a longer hold floor than its real word count.

Refs heygen-com#6338

@jrusso1020 jrusso1020 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.

Approved. Contractions with straight or curly apostrophes now count as one word, surrounding quotes stay out, and the old regex fails the new test. CJK and hold-time rules are unchanged. Thanks!

@jrusso1020
jrusso1020 added this pull request to the merge queue Oct 25, 2026

This branch has not been deployed

No deployments
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.

2 participants