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/language-module.properties in the Java classpath. See http://wiki.languagetool.org/java-api for details.
at org.languagetool.Languages.getLanguageForShortCode(Languages.java:151)
at org.languagetool.synthesis.en.EnglishSynthesizer.<init>(EnglishSynthesizer.java:61)
at org.languagetool.rules.en.AbstractEnglishSpellerRule.<init>(AbstractEnglishSpellerRule.java:34)
at org.languagetool.rules.en.MorfologikBritishSpellerRule.<init>(MorfologikBritishSpellerRule.java:34)
at org.languagetool.language.BritishEnglish.getRelevantRules(BritishEnglish.java:48)
at org.languagetool.JLanguageTool.getAllBuiltinRules(JLanguageTool.java:265)
at org.languagetool.JLanguageTool.<init>(JLanguageTool.java:184)
at org.languagetool.JLanguageTool.<init>(JLanguageTool.java:165)
at nancy.test1.App.main(App.java:37)

(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.