[Solved] Check-create rules deal with grammar.xml

Hi, I have installed languagetool via maven.

In the documentation it states that I must edit the grammar.xml in order to add rules.
Since this file doesn’t exist (through maven), I have to create it as I understand and see here.

I downloaded languagetool in order to check the file and I can see that it exists in …/rules/en and also in …/rules/en/en-US.

Which version should I use?
Just copy paste and I will not have a problem?

Thanks!

When using Maven, the grammar rules are in a JAR file, e.g. for English it’s language-en-3.8.jar. But as you’re using Java anyway, I’d suggest you add rules via the API. Use PatternRuleLoader (LanguageTool 6.0 API) to load your rules and add them using JLanguageTool (LanguageTool 6.0 API)

Can you give me a small example, how to use addRule?

And if I want to edit an already rule, is that possible?And if yes, at which grammar.xml should I search?In /rule/en or in /rule/en/en-US ?

Thank you!

Not via the API, unless you remove the rule and then re-add it maybe (not tested).

en/grammar.xml is used for en-GB and en-US, en-US/grammar.xml is additionally used for en-US.

Ok, can you provide me please with a small example that uses addRule?.
Because I am not sure how to add a rule like this.

Thanks.

Ok, so I must use a custom xml amd add it.Ok.

I thought I had to write java code for the rule.