LanguageTool |
Development |
|
|
This is a collection of the developer documentation available for LanguageTool.
It's intended for people who want to understand LanguageTool so
they can write their own rules or even add support for a new language.
Software developers might also be interested in LanguageTool's
Help wanted!We're looking for people who support us writing new rules so LanguageTool can detect more errors. Also seeHow can you help?
Source code Checkout (Java developers only)If you are a Java developer and you want to extend LanguageTool or if you want to use the latest development version, check out LanguageTool from subversion:
svn co https://languagetool.svn.sourceforge.net/svnroot/languagetool/trunk/JLanguageTool languagetool
You can then run the test with ant test or build the code with ant. Installation and usagePlease see theLanguage checking process
Adding new XML rulesMost rules are contained in rules/xx/grammar.xml, whereas xx is a language code like en or de. A rule is basically a pattern which shows an error message to the user if the pattern matches. A pattern can address words or part-of-speech tags. Here are some examples of patterns that can be used in that file:
A pattern's terms are matched case-insensitively by default. This can be changed by setting the pattern's case_sensitive attribute to yes. Here's an example of a complete rule that marks "bed English", "bat attitude" etc as an error: <rule id="BED_ENGLISH" name="Possible typo 'bed/bat(bad) English/...'">
<pattern mark_from="0" mark_to="-1"> <token regexp="yes">bed|bat</token> <token regexp="yes">English|attitude</token> </pattern> <message>Did you mean<suggestion>bad</suggestion>?</message> <url>http://some-server.org/the-bed-bad-error</url> <example type="correct">Sorry for my <marker>bad</marker> English.</example> <example type="incorrect">Sorry for my <marker>bed</marker> English.</example> </rule> A short description of the elements and their attributes:
There are more features not used in the example above:
Adding new Java rulesRules that cannot be expressed with a simple pattern in grammar.xml can be developed as a Java class. See rules/WordRepeatRule.java for a simple example which you can use to develop your own rules. You will also need to add your rule's id to <YourLanguage>.java to activate it.Translating the user interfaceWe use Transifex to translate our property files. Updated translations are only copied to the LanguageTool source before a release, so if you need an early preview, say so on the LanguageTool mailing list and we'll update the files accordingly.Adding support for a new languageAdding a new language requires some changes to the Java source files. You should check out the "JLanguageTool" module from subversion (see above or the sourceforge help). You may then call ant to build LanguageTool. Ant should compile a file named like LanguageTool-1.x.y-dev.oxt in the dist directory.
Background informationFor some background information, Daniel Naber's diploma thesis about the original version of LanguageTool is available - please note that this refers to an earlier version of LanguageTool which was written in Python):Page last modified: 2012-05-11 |
Time to generate page: 0.05s