Skip to content

Streamline built-in speech dictionary rules#19518

Closed
codeofdusk wants to merge 1 commit into
nvaccess:masterfrom
codeofdusk:better-builtindict-regex
Closed

Streamline built-in speech dictionary rules#19518
codeofdusk wants to merge 1 commit into
nvaccess:masterfrom
codeofdusk:better-builtindict-regex

Conversation

@codeofdusk

@codeofdusk codeofdusk commented Jan 27, 2026

Copy link
Copy Markdown
Contributor

Link to issue number:

None

Summary of the issue:

The built-in speech dictionary includes regular expressions that split text such as NVDAObject, HTMLParser, and issue123 for speech. The previous digit-suffix expression could perform very poorly on long word-character runs that do not contain trailing digits. This can hurt speech responsiveness for pathological text, long mixed-case text, and text containing many digit boundaries.

Description of how this pull request fixes the issue:

Replaced the three built-in dictionary regexes with zero-width boundary matches and literal space insertion. This avoids capture groups and, most importantly, replaces the old digit-suffix regex with a direct word-to-digit boundary check.

The lookarounds are ordered so the forward assertion is checked first. Most positions fail based on the next character, so this avoids unnecessary previous-character checks and improves performance further.

Testing strategy:

Verified equivalent output between master and this branch on:

  • The benchmark scenarios below.
  • 10,000 generated ASCII samples containing letters, digits, underscores, spaces, and punctuation.

Tested with this benchmarking script (LLM generated).

Default NVDA regex engine (re):

Scenario master median branch median Difference
short mixed phrase 0.007265 ms 0.002236 ms 3.25 times faster
camel/acronym dense 1.291176 ms 0.296330 ms 4.36 times faster
number suffix dense 0.369622 ms 0.335921 ms 1.10 times faster
mixed identifier log 1.772693 ms 0.430847 ms 4.11 times faster
plain lowercase words 3.372053 ms 0.292519 ms 11.53 times faster
single long word no digits 240.882400 ms 0.088500 ms 2721.84 times faster
long identifier no digits 1.689099 ms 0.141683 ms 11.92 times faster

Also tested with the optional modern regular expression engine. The same main improved scenarios held.

Known issues with pull request:

With the default NVDA regex engine, all benchmark scenarios are now faster than master.

With the optional modern regex engine, the number-suffix dense benchmark remains slower than master. That engine is opt-in, and the main intended improvement is for no-match and mixed-case text, especially long word-character runs without digits, where the old expression was pathological.

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

@seanbudd

Copy link
Copy Markdown
Member

@codeofdusk do you still plan on working on this?

@seanbudd

seanbudd commented Mar 5, 2026

Copy link
Copy Markdown
Member

Closing. Feel free to reopen when tested and ready

@seanbudd seanbudd closed this Mar 5, 2026
@seanbudd seanbudd added the Abandoned requested reports or updates are missing since more than 1 year, author or users are not available. label Mar 5, 2026
@codeofdusk

Copy link
Copy Markdown
Contributor Author

@seanbudd I don't see an option to reopen this PR, are you able to do this from your end?

@seanbudd

seanbudd commented Jul 1, 2026

Copy link
Copy Markdown
Member

It can no longer be reopened through the GitHub UX

@codeofdusk

Copy link
Copy Markdown
Contributor Author

It can no longer be reopened through the GitHub UX

OK, replaced by #20433.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Abandoned requested reports or updates are missing since more than 1 year, author or users are not available. blocked/needs-testing blocked

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants