languagetool-org / languagetool-website-2018

OUTDATED, do not use anymore
12 stars 11 forks source link

Use different colors for error types from grammar.xml #53

Closed f-knorr closed 3 years ago

f-knorr commented 5 years ago

I have recently added some error type to categories in de-DE-x-simple-language/grammar.xml: <category id="DIFFICULT_WORDS" name="Schwierige Wörter und Wendungen" type="misspelling"> In the standalone application this leads to different color for errors in this category. unbenannt The online version does not show a different color: grafik Can this be fixed?

danielnaber commented 5 years ago

Where do these colors come from? Isn't that just a local .languagetool.cfg thing?

f-knorr commented 5 years ago

Maybe. However, I did not change these setting, so they must be the default ones. I think it's pretty obvious that one expects that type="misspelling" uses the same color scheme as an actual spelling error.

danielnaber commented 5 years ago

Mhh, isn't this somehow a misuse of type=misspelling, only to get the desired color? My gut feeling tells me it would make more sense to find a more general solution. However, we then have to decide who sets the colors. The frontend or the backend? I think this is a typical frontend task. But should we then just extend the frontend to have a mapping between rule ids / categories and colors? The web front has that already (adt.core2.js), in form of a simple if/elseif branch.

f-knorr commented 5 years ago

I think we should consider two points here:

  1. How should we deal with type="misspelling in general? The English grammar.xml, for example, has such a category which lists AFAIK real misspellings:

    <category id="CONFUSED_WORDS" name="Commonly Confused Words" type="misspelling">
        <rulegroup id="BLU_RAY" name="Blue-ray (Blu-ray)">
            <rule>
                <pattern case_sensitive="yes">
                    <token regexp="yes">Blueray|blueray|BlueRay|Blue-ray|blue-ray|Blue-Ray|Blu-Ray|blu-ray</token>
                </pattern>
                <message>Did you mean <suggestion>Blu-ray</suggestion>?</message>
                <short>Possible typo</short>
                <example correction="Blu-ray">I ordered a <marker>Blueray</marker> disk with their software.</example>
                <example>I ordered a <marker>Blu-ray</marker> with their software.</example>
            </rule>

    I think this is a good example where the default red colour is very well justified. This comes pretty close to the entries of the German prohibited.txt where we treat correctly constructed words as misspellings.

  2. Is the type="misspelling" a misuse in the case of simple German? Maybe! But I think this language is a edge case because in simple German correctly spelled words, correct grammatical constructions and, for instance, metaphors are regarded as errors in the context of simple German. Therefore, I think it would be justified to mark correctly spelled words that are not allowed in the context of simple German as spelling errors (similar to prohibited.txt)

danielnaber commented 5 years ago

I've changed the website to consider typeName == UnknownWord as a spelling error, but "asymmetrische" is still yellow. Maybe category doesn't properly inherit that attribute to the rule? I don't have time now to debug that.