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

[en] Case conversion does not give the correct result for UPPER CASE text #7125

Closed
MikeUnwalla opened this issue Sep 26, 2022 · 3 comments
Closed

Comments

@MikeUnwalla
Copy link
Contributor

MikeUnwalla commented Sep 26, 2022

"Note: LT automatically adjusts the case of suggestions if they are added as plain text." (https://dev.languagetool.org/tips-and-tricks#changing-the-case-of-matched-word)

        <rule id="CASE_CONVERSION_TEST" name="Case conversion test">
            <pattern>
                <token>cat</token>
            </pattern>
            <message>Use '<suggestion>dog</suggestion>'.</message>
            <example correction="dog">My <marker>cat</marker> is happy.</example>
            <example correction="Dog">My <marker>Cat</marker> is fat.</example>
            <example correction="DOG">MY <marker>CAT</marker> SAT ON THE MAT.</example>
        </rule>

Testrules gives this message (LanguageTool-20220919-snapshot.zip):

Exception in thread "main" org.languagetool.rules.patterns.PatternRuleTest$PatternRuleTestFailure: Test failure for rule CASE_CONVERSION_TEST[1] in file /org/languagetool/rules/en/grammar.xml: Incorrect suggestions: Expected 'DOG', got: 'Dog' on input: 'MY CAT SAT ON THE MAT.'

@jaumeortola
Copy link
Member

You are right. The default behaviour of the suggestions should be similar to case_converson="preserve" for all languages. I will take a look. Probably, we will need to adjust some tests in many languages.

@jaumeortola
Copy link
Member

jaumeortola commented Jul 16, 2023

All-uppercase suggestions have been implemented.

Once we preserve the case for all-uppercase words in the original sentence automatically, rule creators will need a way to make exceptions to all-uppercase suggestions. The way to do that, is to use a <match> with a case_conversion attribute:

<suggestion><match no="2" regexp_match="^.*$" regexp_replace="Liebe Grüße" case_conversion="startupper"/></suggestion>

The <match> has to be at the start of the first suggestion. This won't work:

<suggestion>L<match no="2" regexp_match="^.*$" regexp_replace="iebe" case_conversion="alllower/></suggestion>

@MikeUnwalla
Copy link
Contributor Author

@jaumeortola , thank you.

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

No branches or pull requests

2 participants