Back to LanguageTool Homepage - Privacy - Imprint

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


#1

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!


(Daniel Naber) #2

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 https://languagetool.org/development/api/org/languagetool/rules/patterns/PatternRuleLoader.html to load your rules and add them using https://languagetool.org/development/api/org/languagetool/JLanguageTool.html#addRule-org.languagetool.rules.Rule-


#3

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!


(Daniel Naber) #4

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.


#5

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.


#6

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

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