Back to LanguageTool Homepage - Privacy - Imprint

Integrating my xml file with language-en-3.7.jar

(Praneet Khandelwal) #1

I downloaded the language tool by including maven dependencies in my JAVA project and now I need to integrate my user_rules.xml (similar to grammar.xml) in the jar file. How do I need to do this?

I just extracted the language-en-3.7.jar and modified the grammar.xml accordingly and compressed to get the jar again. But when run, it gives me the following error -

Exception in thread "main" java.lang.IllegalArgumentException: 'en' is not a language code known to LanguageTool. Supported language codes are: . The list of languages is read from META-INF/org/languagetool/ in the Java classpath. See for details.
at org.languagetool.Languages.getLanguageForShortCode(
at org.languagetool.synthesis.en.EnglishSynthesizer.<init>(
at org.languagetool.rules.en.AbstractEnglishSpellerRule.<init>(
at org.languagetool.rules.en.MorfologikBritishSpellerRule.<init>(
at org.languagetool.language.BritishEnglish.getRelevantRules(
at org.languagetool.JLanguageTool.getAllBuiltinRules(
at org.languagetool.JLanguageTool.<init>(
at org.languagetool.JLanguageTool.<init>(
at nancy.test1.App.main(

(Daniel Naber) #2

My guess is that your new JAR has a different structure, maybe you added or removed one level of directories. The JAR must have exactly the same structure as before. Anyway, the clean solution is to use the API to activate your rules, using JLanguageTool.addRule(). You can load your rules using org.languagetool.rules.patterns.PatternRuleLoader.