Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 11165 -- turn off space rule for fr-CA #11175

Closed
wants to merge 3 commits into from

Conversation

danielnaber
Copy link
Member

@danielnaber danielnaber commented Jan 9, 2025

See #11165

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced language-specific rule filtering for more precise language tool configurations
    • Added support for demo language testing scenarios
  • Improvements

    • Updated rule handling for Balearic and Valencian Catalan language variants
    • Expanded Spanish Voseo language configuration
    • Modified Canadian French language rule settings
  • Dictionary Updates

    • Added new German language terms related to construction and energy sectors
  • Testing

    • Introduced comprehensive demo rule testing framework

@danielnaber danielnaber requested a review from SteVio89 January 9, 2025 11:15
Copy link
Contributor

coderabbitai bot commented Jan 9, 2025

Walkthrough

The pull request introduces changes to the LanguageTool core and language modules, focusing on rule filtering and language-specific configurations. The primary modification is in the JLanguageTool class, where a new filtering mechanism is added to the getAllBuiltinRules method. This change allows for excluding rules that are marked as disabled for specific language variants. Additionally, the PR includes updates to various language modules, such as adding test cases, modifying rule configurations, and expanding spelling resources.

Changes

File Change Summary
languagetool-core/src/main/java/org/languagetool/JLanguageTool.java Added filtering mechanism in getAllBuiltinRules to exclude rules disabled for specific language variants
languagetool-core/src/test/java/org/languagetool/rules/DemoRuleTest.java New test class added to validate rule functionality across different language configurations
languagetool-language-modules/ca/src/main/java/org/languagetool/language/BalearicCatalan.java Removed comment in getDefaultDisabledRulesForVariant method
languagetool-language-modules/ca/src/main/java/org/languagetool/language/ValencianCatalan.java Removed comment in getDefaultDisabledRulesForVariant method
languagetool-language-modules/de/src/main/resources/org/languagetool/resource/de/hunspell/spelling.txt Added new spelling entries: Vorjahreszubau, Solarzubau, Repowering, Inbetriebnahmezahl, Inbetriebnahmezahlen
languagetool-language-modules/es/src/main/java/org/languagetool/language/SpanishVoseo.java Added constructor, modified getCountries and getDefaultDisabledRulesForVariant methods
languagetool-language-modules/fr/src/main/java/org/languagetool/language/CanadianFrench.java Updated getDefaultDisabledRulesForVariant to include an additional rule

Possibly related PRs

Suggested reviewers

  • jaumeortola

Finishing Touches

  • 📝 Generate Docstrings

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>, please review it.
    • 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 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 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 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. (Beta)
  • @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.

Solarzubau/S
Repowering/S #eng
Inbetriebnahmezahl
Inbetriebnahmezahlen
Copy link
Member Author

Choose a reason for hiding this comment

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

doesn't belong here, of course...

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
languagetool-language-modules/es/src/main/java/org/languagetool/language/SpanishVoseo.java (1)

19-19: Clean up commented country codes

The line contains commented-out country codes (PA, UY, CR). If these countries aren't currently supported, the comments should be removed. If they will be supported in the future, consider:

  1. Adding a TODO comment explaining the plan
  2. Creating a tracking issue for adding support for these countries
-    return new String[] { "AR" }; //, "PA" , "UY", "CR"
+    return new String[] { "AR" };
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 43db845 and 8fcc74c.

📒 Files selected for processing (7)
  • languagetool-core/src/main/java/org/languagetool/JLanguageTool.java (1 hunks)
  • languagetool-core/src/test/java/org/languagetool/rules/DemoRuleTest.java (1 hunks)
  • languagetool-language-modules/ca/src/main/java/org/languagetool/language/BalearicCatalan.java (0 hunks)
  • languagetool-language-modules/ca/src/main/java/org/languagetool/language/ValencianCatalan.java (0 hunks)
  • languagetool-language-modules/de/src/main/resources/org/languagetool/resource/de/hunspell/spelling.txt (1 hunks)
  • languagetool-language-modules/es/src/main/java/org/languagetool/language/SpanishVoseo.java (2 hunks)
  • languagetool-language-modules/fr/src/main/java/org/languagetool/language/CanadianFrench.java (2 hunks)
💤 Files with no reviewable changes (2)
  • languagetool-language-modules/ca/src/main/java/org/languagetool/language/BalearicCatalan.java
  • languagetool-language-modules/ca/src/main/java/org/languagetool/language/ValencianCatalan.java
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (java-kotlin)
🔇 Additional comments (9)
languagetool-language-modules/fr/src/main/java/org/languagetool/language/CanadianFrench.java (1)

21-21: LGTM! The changes correctly implement the space rule disabling for fr-CA.

The implementation:

  1. Properly switches from Collections.singletonList() to Arrays.asList() as we now have multiple rules
  2. Correctly adds the "FRENCH_WHITESPACE" rule to the disabled rules list

Also applies to: 49-51

languagetool-core/src/test/java/org/languagetool/rules/DemoRuleTest.java (2)

39-47: LGTM! Well-structured test cases that verify rule disabling functionality.

The test cases effectively verify:

  1. Basic rule matching (line 42-43)
  2. Rule disabling behavior (line 44-46)

78-83: LGTM! Good test coverage for disabled rules.

The DemoLang2 class properly demonstrates how to disable rules by adding them to the default disabled rules list.

languagetool-core/src/main/java/org/languagetool/JLanguageTool.java (1)

478-480: LGTM! Efficient implementation of rule filtering for language variants.

The implementation:

  1. Correctly checks for disabled rules using getDefaultDisabledRulesForVariant()
  2. Efficiently filters the rules using Stream API
  3. Maintains the existing behavior for languages without disabled rules
languagetool-language-modules/de/src/main/resources/org/languagetool/resource/de/hunspell/spelling.txt (2)

65837-65841: LGTM! New entries follow German compound word formation rules

The additions are well-formed:

  • Compound words follow correct German word formation rules
  • Plural forms are properly indicated with /S suffix where applicable
  • Terms are relevant to construction and energy sectors

65839-65839: Verify the common usage of the English loanword "Repowering"

The term is correctly marked with #eng comment. However, let's verify its widespread usage in German technical documentation.

✅ Verification successful

The "Repowering/S" entry is correctly formatted and valid

While there's limited usage in the codebase, this is an established technical term in the German energy sector, particularly in wind energy contexts. The entry is properly marked as an English loanword (#eng) and correctly includes the plural form suffix (/S).

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for "Repowering" usage in German documentation
rg -i "repowering" . --type=txt --glob="**/de/**"

Length of output: 173


Script:

#!/bin/bash
# Broader search for Repowering and its compounds
rg -i "repowering" . --glob="!*.class" --glob="!*.jar"

# Search for compound words with Repowering
rg -i "[a-z]*repowering[a-z]*|repowering[a-z]*|[a-z]*repowering" . --glob="!*.class" --glob="!*.jar"

# Search specifically in documentation files
rg -i "repowering" . --glob="*.md" --glob="*.txt" --glob="*.html" --glob="*.xml" --glob="*.properties"

Length of output: 632

languagetool-language-modules/es/src/main/java/org/languagetool/language/SpanishVoseo.java (3)

24-26: 🛠️ Refactor suggestion

Return an immutable list to prevent modifications

The method returns a mutable list which could be modified by callers. Since this is a configuration method, it's safer to return an immutable list.

-    return rules;
+    return Collections.unmodifiableList(rules);

Likely invalid or redundant comment.


8-10: Verify the purpose of the boolean parameter in super constructor

The constructor calls super(true), but the purpose of this boolean parameter isn't immediately clear. Consider adding a comment explaining its significance or using a more descriptive constant.

Let's check the parent class implementation:

✅ Verification successful

The boolean parameter in super constructor is a framework implementation detail

The super(true) call is using a protected constructor in the parent Spanish class that's specifically designed as a "fake" constructor for subclasses. The boolean parameter has no functional purpose - it's just a marker to differentiate between public and protected constructors, preventing direct instantiation except through the language tool framework.

Consider adding a comment explaining this implementation detail:

public SpanishVoseo() {
    // Protected constructor for language variants, boolean parameter is a framework requirement
    super(true);
}
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find the Spanish.java parent class implementation
ast-grep --pattern 'class Spanish {
  $$$
  Spanish(boolean $_) {
    $$$
  }
  $$$
}'

Length of output: 88


Script:

#!/bin/bash
# Find Spanish.java file
fd Spanish.java

# Once found, let's examine its content
fd Spanish.java --exec cat {}

Length of output: 14741


Line range hint 1-28: Verify if these Spanish language changes are intended

The PR's objective is to turn off the space rule for fr-CA, but this file contains changes to Spanish language support. Please confirm if these changes are intentional or if they were accidentally included in this PR.

Let's check for related changes in fr-CA files:

}

@Override
public List<String> getDefaultDisabledRulesForVariant() {
List<String> rules = Collections.singletonList("VOSEO");
return Collections.unmodifiableList(rules);
return rules;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just do

return Collections.singletonList("VOSEO");

@@ -46,7 +46,7 @@ public String[] getCountries() {

@Override
public List<String> getDefaultDisabledRulesForVariant() {
List<String> rules = Collections.singletonList("DOUBLER_UNE_CLASSE");
List<String> rules = Arrays.asList("DOUBLER_UNE_CLASSE", "FRENCH_WHITESPACE");
Copy link
Collaborator

Choose a reason for hiding this comment

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

just do

return Arrays.asList("DOUBLER_UNE_CLASSE", "FRENCH_WHITESPACE");

@danielnaber
Copy link
Member Author

@SteVio89 Thanks for the review. Just after submitting the PR, I noticed we have this case covered already in the front-end, so I'll close this.

@danielnaber danielnaber closed this Jan 9, 2025
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