Skip to content

implement accent/diacritic ignore search#1724

Merged
hahn-kev merged 8 commits into
developfrom
diacritic-search
Jun 5, 2025
Merged

implement accent/diacritic ignore search#1724
hahn-kev merged 8 commits into
developfrom
diacritic-search

Conversation

@hahn-kev

@hahn-kev hahn-kev commented Jun 4, 2025

Copy link
Copy Markdown
Collaborator

closes #1718

Expected implementation:

Search Headword Matches
A A
A Ã
à A
à Ã

Actual:

Search Headword Matches
A A
A Ã
à A
à Ã

this also raised some normalization issues, so I'm going to get some input from Jason on that.

@coderabbitai

coderabbitai Bot commented Jun 4, 2025

Copy link
Copy Markdown

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

A custom SQLite function and supporting logic were added to enable case-insensitive and diacritic-insensitive string searching within the database context. The search logic and tests were updated to ensure that searching for characters like "A" will also match entries with "Ã", according to invariant culture rules. New extension methods for culture-aware string comparison were introduced.

Changes

Files/Groups Change Summary
backend/FwLite/LcmCrdt/Data/CustomSqliteFunctionInterceptor.cs Added new interceptor class to register a custom SQLite "contains" function for case-insensitive, accent-insensitive string search.
backend/FwLite/LcmCrdt/LcmCrdtDbContext.cs Modified OnConfiguring to add the new interceptor for custom SQLite functions.
backend/FwLite/LcmCrdt/SqlHelpers.cs Updated search logic to use new method for culture-aware, diacritic-insensitive string containment; added method with SQL translation attribute.
backend/FwLite/MiniLcm.Tests/QueryEntryTestsBase.cs Added parameterized tests covering case and accent-insensitive search scenarios.
backend/FwLite/MiniLcm.Tests/SerializationTests.cs Added new using directives; no functional/test logic changes.
backend/FwLite/MiniLcm/Culture/StringExtensions.cs Introduced new static class with extension methods for culture-aware string containment and equality checks.

Assessment against linked issues

Objective Addressed Explanation
Enable search for "A" to match both "A" and "Ã" (diacritic-insensitive, case-insensitive search) (#1718)
Ensure "Ã" does not match "A" when searching for "Ã" (asymmetric matching per table) (#1718)
Ensure "A" matches "A" and "Ã" matches "Ã" (#1718)

Poem

In the meadow of code, a search takes flight,
Where "A" and "Ã" now both shine bright.
With accents ignored and cases unseen,
The rabbits hop through fields so keen.
Culture-aware, they leap with glee—
"Find all the words that belong to me!"
🐇✨


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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>, please review it.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 using 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

@argos-ci

argos-ci Bot commented Jun 4, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Jun 5, 2025, 8:08 AM

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (1)
backend/FwLite/MiniLcm.Tests/SerializationTests.cs (1)

1-4: Verify necessity of unused using directives.

The added using directives for System.Globalization, System.Text, and MiniLcm.Culture don't appear to be used in this file. Consider removing them unless they're needed for future changes.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between be4f7e0 and 2927b3d.

📒 Files selected for processing (6)
  • backend/FwLite/LcmCrdt/Data/CustomSqliteFunctionInterceptor.cs (1 hunks)
  • backend/FwLite/LcmCrdt/LcmCrdtDbContext.cs (1 hunks)
  • backend/FwLite/LcmCrdt/SqlHelpers.cs (2 hunks)
  • backend/FwLite/MiniLcm.Tests/QueryEntryTestsBase.cs (2 hunks)
  • backend/FwLite/MiniLcm.Tests/SerializationTests.cs (1 hunks)
  • backend/FwLite/MiniLcm/Culture/StringExtensions.cs (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
backend/FwLite/LcmCrdt/SqlHelpers.cs (4)
backend/FwLite/LcmCrdt/Json.cs (8)
  • Json (12-200)
  • Sql (116-123)
  • Sql (125-132)
  • Sql (173-177)
  • Sql (179-183)
  • Expression (142-145)
  • Expression (153-156)
  • Expression (166-169)
backend/FwLite/LcmCrdt/Data/Filtering.cs (1)
  • Expression (15-20)
backend/FwLite/LcmCrdt/Data/CustomSqliteFunctionInterceptor.cs (1)
  • CustomSqliteFunctionInterceptor (9-33)
backend/FwLite/MiniLcm/Culture/StringExtensions.cs (1)
  • Contains (7-10)
backend/FwLite/LcmCrdt/LcmCrdtDbContext.cs (1)
backend/FwLite/LcmCrdt/Data/CustomSqliteFunctionInterceptor.cs (1)
  • CustomSqliteFunctionInterceptor (9-33)
backend/FwLite/LcmCrdt/Data/CustomSqliteFunctionInterceptor.cs (1)
backend/FwLite/MiniLcm/Culture/StringExtensions.cs (1)
  • Contains (7-10)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Build FwHeadless / publish-fw-headless
  • GitHub Check: frontend
  • GitHub Check: Build FW Lite and run tests
  • GitHub Check: Analyze (csharp)
🔇 Additional comments (8)
backend/FwLite/LcmCrdt/LcmCrdtDbContext.cs (1)

18-18: LGTM! Custom SQLite function properly integrated.

The addition of CustomSqliteFunctionInterceptor correctly integrates the culture-aware string comparison functionality into the EF Core pipeline, enabling the custom "contains" function for LINQ-to-SQL translation.

backend/FwLite/LcmCrdt/SqlHelpers.cs (2)

1-6: LGTM! Required using directives properly added.

The new using directives correctly support the culture-aware string comparison functionality and SQLite function integration.


31-31: LGTM! Search logic updated to use culture-aware comparison.

The change from direct string.Contains to ContainsIgnoreCaseAccents correctly implements the accent/diacritic insensitive search functionality.

backend/FwLite/MiniLcm.Tests/QueryEntryTestsBase.cs (1)

1-1: LGTM! Required using directive added.

The System.Text using directive is correctly added to support Unicode normalization in the new tests.

backend/FwLite/MiniLcm/Culture/StringExtensions.cs (2)

7-10: Well-implemented culture-aware Contains method.

The implementation correctly uses CompareInfo.IndexOf with the appropriate return value check. This provides a solid foundation for culture-sensitive string searches.


12-18: Well-implemented culture-aware Equals method.

The implementation correctly uses CompareInfo.Compare and checks for zero return value to determine equality. The method signature and default parameter handling are appropriate.

backend/FwLite/LcmCrdt/Data/CustomSqliteFunctionInterceptor.cs (2)

19-19: Good null safety handling.

The null checks prevent potential exceptions when either parameter is null.


26-32: Proper async implementation.

The async method correctly delegates to the synchronous version and returns a completed task, which is appropriate for this interceptor pattern.

Comment thread backend/FwLite/LcmCrdt/SqlHelpers.cs Outdated
Comment thread backend/FwLite/MiniLcm.Tests/QueryEntryTestsBase.cs
Comment thread backend/FwLite/MiniLcm.Tests/QueryEntryTestsBase.cs
Comment thread backend/FwLite/LcmCrdt/Data/CustomSqliteFunctionInterceptor.cs
Comment thread backend/FwLite/LcmCrdt/Data/CustomSqliteFunctionInterceptor.cs

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

Looks good! 💪 🎉
I pushed some tiny harmless changes.

hahn-kev added 2 commits June 5, 2025 15:06
…e in the search string, otherwise it does match
rip out diacritic check cache since it's actually slower to lookup the result
@hahn-kev hahn-kev merged commit 9c1d75e into develop Jun 5, 2025
16 checks passed
@hahn-kev hahn-kev deleted the diacritic-search branch June 5, 2025 08:48
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.

Searching for A should show results with Ã

2 participants