Choosing among the different URLs of a rule

Several URLs can be added to each LanguageTool rule. But it seems that there is no way to choose one of the different URLs. In fact, only the last URL is added to the rule and shown to the users.

I have a proposal to enable the selection. We could use a parameter in a configuration file like:

allow_infourls_containing=example.com;wikipedia.org;mygrammarhelp

If the URL doesn’t contain any of these strings, the URL is ignored. On the other hand, if the URL contains one of these strings, the URL is selected as the info link of the rule.

Could this idea be implemented?

Several URLs can be added to each LanguageTool rule.

How? If I put 2 URLs in a rule, I get a testrules error.

On the other hand, if the URL contains one of these strings, the URL is selected as the info link of the rule.

Currently, a rule shows only 1 URL. If the new parameter makes a rule show only 1 URL, what is the purpose of the proposed change?

Thanks for the comments.

I am writing sometimes two <url></url>, one after another, and I don’t get any error. But according to rules.xsd, I probably should get one. Is it possible that some tests are disabled for Catalan? I don’t get any testrules error when I mistype <exmaple> instead of <example>.

The JSON API is prepared to return several URLs, but it is never used:

 "urls": [
          {
            "value": "https://..."
          }
        ],

The purpose is to be able to have different LanguageTool installations for different users with different needs (i.e. different and sometimes incompatible style guides).

Some users want only links to certain sources (e.g. its own style guide). Up to now I have been able to do this filtering out the undesired links. But now I need to add more than one URL to some rules.

Can we think of a solution that is general enough for all current and future needs?

How exactly do you run the tests? I get an error with invalid XML when I run ./build.sh ca test.

I run ./build.sh ca test. There is an error if I mistype only one tag (<exmaple>....</example>):

Caused by: org.xml.sax.SAXParseException; lineNumber: 156; columnNumber: 36; The element type "exmaple" must be terminated by the matching end-tag "</exmaple>".

But I don’t get any error if I mistype both in the same way, because of autocompletion in my text editor (<exmaple>....</exmaple>).

What about multiple URLs? Should I get an error?

If the XSD doesn’t allow that, yes. There’s indeed a bug in the test:

Running XML validation for ca/ca-ES/grammar.xml...
No rule file found at /org/languagetool/rules/ca/ca-ES/grammar.xml in classpath

So it’s trying to test ca-ES/grammar.xml, which doesn’t exist, thus ca/grammar.xml isn’t considered at all. If anybody has time to look for a fix, that would be great. I’ll open a bug report and link it here.

Issue now at ca/grammar.xml not tested · Issue #2231 · languagetool-org/languagetool · GitHub

The Catalan XML validation is fixed. (But I will try to improve the internal logic of the code.)

We can discuss a solution for multiple URL (not for the next release).

  • We could allow and keep several URL per rule, so that a LanguageTool client can select URLs (one or more per match) according to some criteria.
  • We could also add a server configuration parameter to filter out some URLs in a specific LT installation.