languagetool-org/languagetool · error · IllegalArgumentException

JSON output format is not implemented for Bitext

Error message

JSON output format is not implemented for Bitext

What it means

Guard inside CommandLineTools option parsing: the --json flag was accepted, but JSON output has never been implemented for bitext mode (checking a text against another language with --bitext/--mother-tongue). The offending input is the combination of --json with bitext options on the command line; the parser rejects it up front instead of producing unsupported output.

Source

Thrown at languagetool-commandline/src/main/java/org/languagetool/commandline/CommandLineParser.java:145

        checkArguments("-c/--encoding", i, args);
        options.setEncoding(args[++i]);
      } else if (args[i].equals("-u") || args[i].equals("--list-unknown")) {
        options.setListUnknown(true);
        if (options.isTaggerOnly()) {
          throw new IllegalArgumentException("You cannot list unknown words when tagging only");
        }
      } else if (args[i].equals("-b")) {
        options.setSingleLineBreakMarksParagraph(true);
      } else if (args[i].equals("--json")) {
        options.setJsonFormat();
        if (options.isApplySuggestions()) {
          throw new IllegalArgumentException("JSON output format makes no sense for automatic application of suggestions");
        }
        if (options.isLineByLine()) {
          throw new IllegalArgumentException("JSON output format is not implemented for \"line by line\" analysis");
        }
        if (options.isBitext()) {
          throw new IllegalArgumentException("JSON output format is not implemented for Bitext");
        }
        if (options.isListUnknown()) {
          throw new IllegalArgumentException("You cannot list unknown words in JSON output format");
        }
      } else if (args[i].equals("-a") || args[i].equals("--apply")) {
        options.setApplySuggestions(true);
        if (options.isTaggerOnly()) {
          throw new IllegalArgumentException("You cannot apply suggestions when tagging only");
        }
        if (options.isJsonFormat()) {
          throw new IllegalArgumentException("JSON output format makes no sense for automatic application of suggestions");
        }
      } else if (args[i].equals("-p") || args[i].equals("--profile")) {
        options.setProfile(true);
        if (options.isJsonFormat()) {
          throw new IllegalArgumentException("JSON output format makes no sense for profiling");
        }
        if (options.isApplySuggestions()) {

View on GitHub (pinned to 2e990059ce)

Solutions

  1. Drop --json when running bitext mode and parse the default output.
  2. Drop -b2/--bitext if the file is monolingual and JSON output is required.
  3. Post-process the default bitext output into JSON yourself in the calling script.

Example fix

// before
languagetool -b2 --json -l en -l2 de file.txt
// after
languagetool -b2 -l en -l2 de file.txt
Defensive patterns

Strategy: validation

Validate before calling

List<String> a = Arrays.asList(args);
if (a.contains("--json") && (a.contains("-b2") || a.contains("--bitext"))) {
  throw new IllegalArgumentException("--json is incompatible with bitext mode");
}

Try / catch

try {
  new CommandLineParser().parseOptions(args);
} catch (IllegalArgumentException e) {
  if (e.getMessage().contains("not implemented for Bitext")) {
    System.err.println("Run bitext checks without --json, or convert the default output to JSON yourself.");
  }
}

Prevention

When it happens

Trigger: `languagetool -b2 --json file.txt` — --bitext parsed before --json.

Common situations: Translation QA pipelines using bitext mode that also want structured JSON output; scripts appending --json for downstream tooling.

Understand the failure class

Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.

Related errors


AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06). Data as JSON: /api/errors/e3122b0782d8cc78. Report an issue: GitHub.