Skip to content

Ensure that when character normalization results in a character with symbol definition, the symbol replacement is spoken#16950

Merged
seanbudd merged 1 commit into
nvaccess:betafrom
LeonarddeR:fixupSilentNormalize
Aug 5, 2024
Merged

Ensure that when character normalization results in a character with symbol definition, the symbol replacement is spoken#16950
seanbudd merged 1 commit into
nvaccess:betafrom
LeonarddeR:fixupSilentNormalize

Conversation

@LeonarddeR

@LeonarddeR LeonarddeR commented Aug 3, 2024

Copy link
Copy Markdown
Collaborator

Link to issue number:

Fixup for #16622

Summary of the issue:

When unicode normalization of a character (e.g. ·) resulted into a character that had a symbol definition (e.g. ·, middle dot), the symbol definition wasn't applied to the normalization. This resulted in NVDA speaking nothing or only the word normalized.

Description of user facing changes

NVDA will now properly speak the · character (Greek Ano Teleia) as middle dot when normalizing. This also applies to other characters where normalization results in a character that's part of the symbol dictionary.

Description of development approach

When normalizing a character, ensure it is thrown through characterProcessing.processSpeechSymbol.

Testing strategy:

  • Tested speaking of the Greek Ano Teleia as middle dot normalized when navigating across it with left/right arrow and normalization was on.
  • Validated unit tests

Known issues with pull request:

None known

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.

Summary by CodeRabbit

  • Style
    • Enhanced code readability with consistent spacing and improved formatting in method definitions.
    • Standardized use of double quotes for string literals across multiple files.
    • Consolidated multi-line conditions and method calls into single lines for clarity.
  • Bug Fixes
    • Improved processing logic for character handling in speech functions, resulting in more accurate speech output.
  • Tests
    • Added new test cases for the _getSpellingSpeechWithoutCharMode function to validate the normalization feature under various conditions.

@LeonarddeR LeonarddeR requested a review from a team as a code owner August 3, 2024 20:35
@LeonarddeR LeonarddeR requested review from michaelDCurran and removed request for a team August 3, 2024 20:35
@coderabbitai

coderabbitai Bot commented Aug 3, 2024

Copy link
Copy Markdown
Contributor

Walkthrough

The recent changes across multiple files primarily focus on code formatting and stylistic improvements. These updates include the standardization of string delimiters, whitespace adjustments, and enhancements to function signatures for better readability. While the core functionality and control flow remain unchanged, the overall aesthetics of the codebase have been significantly improved, enhancing maintainability and consistency.

Changes

Files Change Summary
appveyor/crowdinSync.py Reformatted function signatures and calls for improved readability; consolidated multi-line statements into single lines.
appveyor/mozillaSyms.py Standardized string delimiters from single to double quotes; adjusted formatting of list comprehensions and function calls for consistency.
extras/controllerClient/examples/example_python.py Replaced single quotes with double quotes in SSML string literals without changing functionality.
projectDocs/dev/developerGuide/conf.py Minor formatting adjustments; standardized quotation marks and added whitespace for readability without altering functionality.
source/speech/speech.py Enhanced character processing in _getSpellingSpeechWithoutCharMode, improving speech output accuracy while keeping control flow intact.
tests/unit/test_speech.py Added new test cases for _getSpellingSpeechWithoutCharMode to improve test coverage for various normalization scenarios.
Other files (various source, appveyor, and extras files) Various formatting changes including whitespace adjustments, consistent use of string delimiters, and minor reorganization of comments for improved readability.

Sequence Diagram(s)

%% No sequence diagrams generated as changes are primarily formatting and do not involve new features or control flow modifications.
Loading

Recent review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e89ccb3 and d433e16.

Files selected for processing (2)
  • source/speech/speech.py (1 hunks)
  • tests/unit/test_speech.py (2 hunks)
Additional context used
Path-based instructions (2)
tests/unit/test_speech.py (2)

Pattern **/*: Focus on code smells, logic errors, edge cases, missing test cases, security flaws and serious issues. Avoid commenting on minor issues such as linting, formatting and style issues. This project uses tabs instead of spaces, do not suggest usage of spaces over tabs. Are there any 'red flags' in this code that might warrant closer investigation from a security standpoint? Explain what makes them suspicious.


Pattern **/*.py: _, pgettext, ngettext, and ngettext are defined globally, errors for this being undefined can be ignored.

source/speech/speech.py (2)

Pattern **/*: Focus on code smells, logic errors, edge cases, missing test cases, security flaws and serious issues. Avoid commenting on minor issues such as linting, formatting and style issues. This project uses tabs instead of spaces, do not suggest usage of spaces over tabs. Are there any 'red flags' in this code that might warrant closer investigation from a security standpoint? Explain what makes them suspicious.


Pattern **/*.py: _, pgettext, ngettext, and ngettext are defined globally, errors for this being undefined can be ignored.

Additional comments not posted (4)
tests/unit/test_speech.py (3)

479-494: Test case test_normalizedInSymbolDict_normalizeOff looks good.

This test case correctly verifies the behavior when normalization is turned off.


496-512: Test case test_normalizedInSymbolDict_normalizeOnDontReport looks good.

This test case correctly verifies the behavior when normalization is enabled but reporting is disabled.


513-530: Test case test_normalizedInSymbolDict_normalizeOnReport looks good.

This test case correctly verifies the behavior when both normalization and reporting are enabled.

source/speech/speech.py (1)

470-472: Enhancement: Process normalized characters through characterProcessing.processSpeechSymbol.

The changes improve handling of normalized characters by ensuring they are processed through characterProcessing.processSpeechSymbol. This ensures that characters with symbol definitions are correctly announced.

However, verify that all edge cases, such as different types of normalization forms, are covered.

Verification successful

Verified: The function _getSpellingSpeechWithoutCharMode is thoroughly tested for various edge cases, including different types of normalization forms.

The tests in tests/unit/test_speech.py ensure that the function handles a wide range of scenarios correctly.

  • tests/unit/test_speech.py: Multiple test cases for _getSpellingSpeechWithoutCharMode covering different input texts and locales.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify edge cases for character normalization in `_getSpellingSpeechWithoutCharMode`.

# Test: Search for function usage and check for edge cases related to normalization.
rg --type python -A 5 $'_getSpellingSpeechWithoutCharMode'

Length of output: 88


Script:

#!/bin/bash
# Description: Verify edge cases for character normalization in `_getSpellingSpeechWithoutCharMode`.

# Test: Search for function usage and check for edge cases related to normalization.
rg --glob '*.py' -A 5 '_getSpellingSpeechWithoutCharMode'

Length of output: 7696


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@LeonarddeR

Copy link
Copy Markdown
Collaborator Author

@seanbudd it looks like @pre-commit-ci is pretty agressive here. I don't know how to tackle that really.

… in a character with symbol definition, the symbol replacement is spoken
@LeonarddeR LeonarddeR force-pushed the fixupSilentNormalize branch 2 times, most recently from bee00b4 to d433e16 Compare August 3, 2024 20:44
@LeonarddeR LeonarddeR changed the title Ensure that when character normalization results in a character with symbol definition, the symbol replacement is spoken [skip pre-commit.ci] Ensure that when character normalization results in a character with symbol definition, the symbol replacement is spoken Aug 3, 2024
@LeonarddeR LeonarddeR force-pushed the fixupSilentNormalize branch from 978bda0 to d433e16 Compare August 3, 2024 20:46
@LeonarddeR LeonarddeR changed the title [skip pre-commit.ci] Ensure that when character normalization results in a character with symbol definition, the symbol replacement is spoken Ensure that when character normalization results in a character with symbol definition, the symbol replacement is spoken Aug 3, 2024

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 14

Comment thread source/NVDAObjects/window/edit.py Outdated
Comment thread source/NVDAObjects/window/_msOfficeChart.py Outdated
Comment thread source/NVDAObjects/IAccessible/sysListView32.py Outdated
Comment thread source/NVDAObjects/IAccessible/sysListView32.py Outdated
Comment thread source/NVDAObjects/IAccessible/sysListView32.py Outdated
Comment thread source/NVDAObjects/IAccessible/sysListView32.py Outdated
Comment thread source/NVDAObjects/IAccessible/sysListView32.py Outdated
Comment thread source/NVDAObjects/IAccessible/sysListView32.py Outdated
Comment thread source/NVDAHelper.py Outdated
Comment thread source/NVDAHelper.py Outdated
@AppVeyorBot

Copy link
Copy Markdown
  • FAIL: Translation comments check. Translation comments missing or unexpectedly included. See build log for more information.
  • PASS: Unit tests.
  • FAIL: Lint check. See test results for more information.
  • PASS: System tests (tags: installer NVDA).
  • Build (for testing PR): https://ci.appveyor.com/api/buildjobs/ovwi4tj0vxnjy9ro/artifacts/output/nvda_snapshot_pr16950-33232,eec004ee.exe
  • CI timing (mins):
    INIT 0.0,
    INSTALL_START 1.1,
    INSTALL_END 0.9,
    BUILD_START 0.0,
    BUILD_END 11.3,
    TESTSETUP_START 0.0,
    TESTSETUP_END 0.3,
    TEST_START 0.0,
    TEST_END 17.8,
    FINISH_END 0.2

See test results for failed build of commit eec004eec7

@seanbudd seanbudd force-pushed the fixupSilentNormalize branch from f962841 to d433e16 Compare August 5, 2024 00:23
@seanbudd

seanbudd commented Aug 5, 2024

Copy link
Copy Markdown
Member

I've had to suspend pre-commit. Hopefully this won't be a problem for long if we avoid PRs to beta.

@seanbudd seanbudd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @LeonarddeR

@seanbudd

seanbudd commented Aug 5, 2024

Copy link
Copy Markdown
Member

@coderabbitai resolve

@seanbudd

seanbudd commented Aug 5, 2024

Copy link
Copy Markdown
Member

@coderabbitai full review

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.

3 participants