LanguageTool

Usage

LanguageTool can be used in a different number of ways:

As a LibreOffice/OpenOffice.org extension

Double click the downloaded LanguageTool-1.x.oxt to install it. If that doesn't work, call Tools -> Extension Manager -> Add.... Close LibreOffice/OpenOffice.org and re-start it. Type some text with an error that LanguageTool can detect and you should see a blue underline. You might want to use "This is an test." as en example – make sure the text language is set to English for this example.

As a stand-alone application

Rename the *.oxt file so it ends with ".zip" and unzip it. Then start LanguageToolGUI.jar by double clicking on it. If your computer isn't configured to start jar archives, start it from the command line using:

java -jar LanguageToolGUI.jar

You can use the --tray option to start LanguageTool inside the system tray. After you copy any text to the clipboard, clicking LanguageTool in the system tray will cause the application to open and check the contents of the clipboard automatically. This way you can use LanguageTool for applications that do not support direct integration of the checker.

As a stand-alone application on the command line

See above, but start LanguageTool.jar using:

java -jar LanguageTool.jar <filename>

LanguageTool only supports plain text files.

Embedding LanguageTool in Java applications

You just need to create a JLanguageTool object and use that to check your text. Also see the API documentation. For example:

JLanguageTool langTool = new JLanguageTool(Language.ENGLISH);
langTool.activateDefaultPatternRules();
List<RuleMatch> matches = langTool.check("A sentence " +
    "with a error in the Hitchhiker's Guide tot he Galaxy");
for (RuleMatch match : matches) {
  System.out.println("Potential error at line " +
      match.getEndLine() + ", column " +
      match.getColumn() + ": " + match.getMessage());
  System.out.println("Suggested correction: " +
      match.getSuggestedReplacements());
}

Using LanguageTool from other applications

Start the stand-alone application and configure it (File -> Options...) to listen on a port that is not used yet (the default port, 8081, should often be okay). This way LanguageTool will also be available in server mode until you stop it. The client that wants to use LanguageTool can now send its text to an URL like this:

http://localhost:8081/?language=xx&text=my+text

The language parameter must specify the two-character language code of the text to be checked. You can also specify motherTongue parameter to specify your mother tongue (for false friend checks). The text parameter is the text itself - you may need to encode it for URLs. If you want to test bilingual text (containing source and translation), simply specify also the srctext parameter. This way bitext mode will be activated automatically. You can use both POST and GET to send your requests to the LanguageTool server.

For the input "this is a test" the LanguageTool server will reply with this XML response:

<?xml version="1.0" encoding="UTF-8"?>
<matches>
<error fromy="0" fromx="0" toy="0" tox="5"
  ruleId="UPPERCASE_SENTENCE_START"
  msg="This sentence does not start with an uppercase letter"
  replacements="This" context="this is a test."
  contextoffset="0"
  errorlength="4"/>

</matches>

You can call http://localhost:8081/Languages to get a list of all languages available.

The server can also be started in a server-only mode (no GUI) on the command line using this command:

java -cp LanguageTool.jar org.languagetool.server.HTTPServer

You can use the --port or -p option to specify the port number. If no port number is specified, the default (8081) is used. For security reasons, the server will not be accessible from other hosts. If you want to run a server for remote users you will need to write a small Java program that creates an instance of org.languagetool.server.HTTPServer.

Page last modified: 2012-03-04