Skip to content

Fix example sentence filter#1667

Merged
hahn-kev merged 2 commits into
developfrom
example-missing-filter-matches-any-sense
May 15, 2025
Merged

Fix example sentence filter#1667
hahn-kev merged 2 commits into
developfrom
example-missing-filter-matches-any-sense

Conversation

@hahn-kev

Copy link
Copy Markdown
Collaborator

Currently only entries with no example sentences will match the filter Senses.ExampleSentences=null, so if there's 2 senses and one has no examples, that entry would not match. This PR changes that so that now it does match the filter.

@coderabbitai

coderabbitai Bot commented May 15, 2025

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This update modifies how example sentences are selected and grouped from lexical senses in two provider classes, changing from a flattened collection to a grouped collection per sense. Additionally, a new test entry and corresponding test cases are added and updated in the test suite, including a new method to verify filtering for entries with senses.

Changes

File(s) Change Summary
backend/FwLite/FwDataMiniLcmBridge/LexEntryFilterMapProvider.cs Changed the EntrySensesExampleSentences property to group example sentences by sense instead of flattening them.
backend/FwLite/LcmCrdt/EntryFilterMapProvider.cs Updated the EntrySensesExampleSentences property to return collections grouped by sense, not a single flat list.
backend/FwLite/MiniLcm.Tests/QueryEntryTestsBase.cs Added a new test entry "Kiwi", updated multiple test cases to include it, and introduced a new filtering test.

Poem

In the garden of code, where senses grow,
Example sentences now group in a row.
"Kiwi" joins the test parade,
Filtering logic freshly displayed!
With every hop and every test,
This bunny ensures your code’s the best.
🥝🐇

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between bc88edf and bf6f071.

📒 Files selected for processing (3)
  • backend/FwLite/FwDataMiniLcmBridge/LexEntryFilterMapProvider.cs (1 hunks)
  • backend/FwLite/LcmCrdt/EntryFilterMapProvider.cs (1 hunks)
  • backend/FwLite/MiniLcm.Tests/QueryEntryTestsBase.cs (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Build FwHeadless / publish-fw-headless
  • GitHub Check: Build FW Lite and run tests
  • GitHub Check: Analyze (csharp)
🔇 Additional comments (8)
backend/FwLite/FwDataMiniLcmBridge/LexEntryFilterMapProvider.cs (1)

20-20: Good fix that aligns with the PR objective.

The change from SelectMany to Select properly maintains the grouping of example sentences per sense, allowing the filter to match entries where at least one sense has no example sentences (which becomes null via EmptyToNull). This change successfully addresses the PR's goal of matching entries with mixed senses (some with examples, some without) when using the filter Senses.ExampleSentences=null.

backend/FwLite/LcmCrdt/EntryFilterMapProvider.cs (1)

16-16:

Details

✅ Verification successful

Consistent implementation across providers.

This change correctly matches the one in LexEntryFilterMapProvider.cs, changing from SelectMany to Select to maintain the per-sense grouping of example sentences, which enables filtering entries with mixed senses correctly.

Note that unlike LexEntryFilterMapProvider.cs, this implementation doesn't use an EmptyToNull conversion. That's likely by design since other collections in this class don't use it either, and the comment on lines 14-15 suggests a different approach to null handling.


🏁 Script executed:

#!/bin/bash
# Description: Verify the consistency between both filter map providers

# Check if both providers have been updated consistently
rg -A 1 "EntrySensesExampleSentences " backend/FwLite/

Length of output: 1089


🏁 Script executed:

#!/bin/bash
# Show the class header and null-handling comment in LcmCrdt EntryFilterMapProvider
sed -n '1,30p' backend/FwLite/LcmCrdt/EntryFilterMapProvider.cs

# Confirm no EmptyToNull usage elsewhere in this provider
rg -n "EmptyToNull" backend/FwLite/LcmCrdt/EntryFilterMapProvider.cs

Length of output: 2651


Approve per-sense grouping for example sentences

Both EntryFilterMapProvider implementations now use Select (not SelectMany) for EntrySensesExampleSentences, ensuring each sense’s examples stay grouped. The LcmCrdt provider deliberately skips an EmptyToNull conversion here—consistent with its broader null-handling strategy (see the EntrySensesSemanticDomainsConverter implementation)—so no further changes are needed.

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

8-8: Good test data addition.

Adding the Kiwi test entry enhances test coverage for the filter behavior changes.


63-83: Well-structured test entry with mixed example sentence coverage.

This test entry for "Kiwi" has a sense with example sentences, which makes it a good counterexample to the entries that should match the Senses.ExampleSentences=null filter, ensuring the filtering logic is correctly tested.


93-98: Good test case addition.

This new test case properly verifies the inverse filtering scenario of CanFilterToMissingSenses, ensuring entries with senses are correctly identified.


112-114: Excellent clarifying comments that explain the filtering behavior.

These comments clearly explain the distinction between entries with no senses vs. entries with senses but no examples, which is essential for understanding the filtering behavior changes implemented in this PR.


115-115: Correct test expectation.

The expected result includes both Peach (which has a sense with no examples) and Banana (which has mixed senses - one with examples, one without), correctly verifying that the updated filter behavior matches entries with at least one sense lacking example sentences.


135-135: Test expectations correctly updated to include Kiwi.

The test cases have been properly updated to include the new Kiwi entry in relevant assertions, ensuring comprehensive test coverage.

Also applies to: 142-142, 149-149, 198-198

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

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

Cool 👍

It would be nice if we could also ensure the objects aren't empty. But that's non-trivial isn't it?

@hahn-kev

Copy link
Copy Markdown
Collaborator Author

Yeah I would say that's a different filter

@hahn-kev hahn-kev merged commit 25d07c7 into develop May 15, 2025
14 checks passed
@hahn-kev hahn-kev deleted the example-missing-filter-matches-any-sense branch May 15, 2025 09:07
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