Back to LanguageTool Homepage - Privacy - Imprint

Adding rules to the xml and checking through the API

(Manya Wadhwa) #1


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!

(Daniel Naber) #2

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.

(Manya Wadhwa) #3

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="">

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:


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?

(Daniel Naber) #4

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

(Manya Wadhwa) #5

Okay. Thanks!