Adding rules to the xml and checking through the API

Hi,

So I made some rules on the rule editor and I want to add them to grammar.xml so that the changes get reflected through the API as well.

I have a local branch setup for language tool. As mentioned in the guidelines( here , “Adding new XML rules”) , I made changes in the grammar.xml at the path: languagetool-language-modules/en/src/main/resources/org/languagetool/

I am trying to access this through the API. So, I had already build languagetool-standalone and started the service. After making the changes, I restarted the service and checked. The changes in the xml were not reflected while detecting the errors.

Do I need to rebuild the languagetool-standalone folder for the changes to be reflected? Or should I make changes to the grammar.xml inside the target foler in languagetool-standalone (I tried this but even this didn’t work).

Any help will be appreciated. Thanks!

This is enough, nothing needs to be rebuilt. You don’t even need the source code. Just download the ZIP (“stand-alone for your desktop”), edit ./org/languagetool/rules/en/grammar.xml, restart LT and you should see the new rules.

In order to verify this, I removed the rules from grammar.xml in the specified location and kept only the basic structure (pasted below).

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../../../../../../../../../languagetool-core/src/main/resources/org/languagetool/rules/print.xsl" ?>
<?xml-stylesheet type="text/css" href="../../../../../../../../../languagetool-core/src/main/resources/org/languagetool/rules/rules.css"
        title="Easy editing stylesheet" ?>
<!DOCTYPE rules [
    <!ENTITY weekdays "Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday">
    <!ENTITY abbrevWeekdays "Mon|Mo|Tue|Tu|Wed|We|Thu|Th|Fri|Fr|Sat|Sa|Sun|Su">
    <!ENTITY months "January|February|March|April|May|June|July|August|September|October|November|December">
    <!ENTITY abbrevMonths "Jan|Feb|Mar|Apr|Jun|Jul|Aug|Sep|Sept|Oct|Nov|Dec">
]>
<rules lang="en" xsi:noNamespaceSchemaLocation="../../../../../../../../../languagetool-core/src/main/resources/org/languagetool/rules/rules.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
</rules>

I restarted the api and checked a couple of errors which were generally marked by language tool. Now, it didn’t catch those, but it is still catching errors like whitespace errors, spelling mistakes etc.

I checked if there are any other grammar xmls in the folder. I found the following:

./org/languagetool/rules/sk/grammar-typography.xml
./org/languagetool/rules/sk/grammar-nezaradene.xml
./org/languagetool/rules/uk/grammar-grammar.xml
./org/languagetool/rules/uk/grammar-punctuation.xml
./org/languagetool/rules/uk/grammar-style.xml
./org/languagetool/rules/uk/grammar-spelling.xml
./org/languagetool/rules/uk/grammar-barbarism.xml

The thing is that the language i’m sending is en-US and these xmls are in sk and uk.

Is there something i’m missing?

That’s expected, as some rules are written in Java, they don’t appear in grammar.xml.

Okay. Thanks!