Back to LanguageTool Homepage - Privacy - Imprint

Help add rules to an external file

Please post your modified grammar.xml file for debugging.

<!DOCTYPE rules [
<!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">
<b><!ENTITY UserRules SYSTEM "file://D:/MyEclipse2015 Workspace/org.languagetool-2.8/src/org/languagetool/rules/en/user-rules.xml"></b>

]>

&UserRules;

Thanks, For my programming skills, could you tell me what’s wrong with my code (below)?
Thanks again.

<!DOCTYPE rules [
<!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">
<!ENTITY UserRules SYSTEM "file://D:/MyEclipse2015 Workspace/org.languagetool-2.8/src/org/languagetool/rules/en/user-rules.xml">

]>

<rule>    
    &UserRules;
    </category>

This works for me:

BEFORE I add

<rule name="!Kumara">    &UserRules;</category>

In my user-rules.xml I have

<rule name="!Kumara">    

...the rules...

</category>

Thanks, and I tried, but still could not activate rules. Could you tell me more detail?

Have you checked Options/Preference to see if your rules appear and are activated?

It’s doesn’t matter, the program is running error. It must be something wrong with grammar.xml, so I want to konw what’s your change(add or del) in grammar.xml and user-rules.xml. Thanks.

Mility [via LanguageTool User Forum] wrote thus at 05:02 PM 10-04-15:

It’s doesn’t matter, the program is running error. It must be
something wrong with grammar.xml, so I want to konw what’s your
change(add or del) in grammar.xml and user-rules.xml. Thanks.

As far as I can tell, I’ve already told you everything. Other points
are as instructed in the help. You’re using a proper xml editor, I
hope. Sometimes, that can show us a minor typo that throws off the whole thing.

Anyway, you have this?

<!DOCTYPE rules [

And sth like this at the end?

<rule name="!Kumara">    &UserRules;</category>

Thanks, I have knew what’s wrong with my grammar.

HI,can you tell me how did you solve this problem?
I have the same error as yours,thx!

Rincy [via LanguageTool User Forum] wrote thus at 01:18 PM 23-11-15:

HI,can you tell me how did you solve this problem? I have the same
error with you,thx!

Please indicate all that you’ve done.

In the grammar.xml, you can follow the above Kumara do. also

<!DOCTYPE rules [

And sth like this at the end?

<rule name="!Mility">    &UserRules;</category>
In addtion, you should add
<rule name="!Mility"  type = "grammar">    
........user-rules here.....
</category>

in user-rules.xml, maybe this could help you.

In my rules-en-English.xml :

<?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 [

]>

<rules lang="en" xsi:noNamespaceSchemaLocation="../../../../../../../../../languagetool-core/src/main/resources/org/languagetool/rules/rules.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">    

        
<rule name="!Rincy" type = "grammar">    
                  <rule ...>
                   ....
                  </rule>

        </category>


    
<rule name="!Rincy">    &UserRules;</category>

OK. I thought so.

This:

<!DOCTYPE rules [

]>

should be merged with the other existing “!DOCTYPE rules”. Using your location of the XML, it should looks like this:

<!DOCTYPE rules [
<!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">
<!ENTITY UserRules SYSTEM "file:///D:\rules-en-English.xml">

]>

Notice the last one.

Thx Kumara,follow your tips,I add the in my rules-en-English.xml file.

I open the my xml file by double clicking the languagetool.jar.
And it still reports the same error :

When I copy these rules to the grammar.xml , they can be matched. So I think the rules are right.
Is the way I open the .xml file wrong?

Rincy wrote: … in my rules-en-English.xml file.

I think that DOCTYPE must be in grammar.xml only.

I want to add external abc.xml file but I am unable to run it. It’s not responding in separate file?
How can I run external abc.xml file?
Above discussion is not helpful because no one told about the proper solution. Please guide me properly.

Thanks

This is documented at http://wiki.languagetool.org/tips-and-tricks#toc10.

1 Like

Hi Daniel
I already have checked that specific page, but I couldn’t find any helpful material could you please explain me with some practical example?

Thanks a bunch

@HaseebTariq,

To make the example as short and as clear as possible, I don’t use the default LT grammar rules in this example. (You can use the default rules and your external rules at the same time.)

Grammar.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rules [
    <!ENTITY MyRules SYSTEM "file:///D:/data-files/grammar-test.xml">
    <!ENTITY apostrophe "['’`´‘]">
]>

<rules lang="en" xsi:noNamespaceSchemaLocation="../../../../../../../../../languagetool-core/src/main/resources/org/languagetool/rules/rules.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

&MyRules;

</rules>

The rules in grammar-text.xml:

  <category id="MY_EXTERNAL_RULES" name="Rules in grammar-test.xml" type="style" external="yes">

    <rule id="CAT_FELINE" name="cat (feline)">
      <pattern>
        <token>cat</token>
      </pattern>
      <message>Don't use simple words. Did you mean 'feline'?</message>
      <short>grammar-test: feline</short>
      <example type="incorrect">The <marker>cat</marker> sat on the mat.</example>
      <example>The <marker>feline</marker> sat on the mat.</example>
    </rule>

  </category>
1 Like